Toggle HTML radio button by clicking its label

Alexander Farber :

Is there please a simple way to make a radio button toggle - when a text near it is clicked - without introducing any big Javascript Framework into my smal PHP project?

The web form looks like this:

<html>
<body>
<form method="post">
<p>Mode:<br /> 
<input type="radio" name="mode" value="create"><i>create table</i><br />
<input type="radio" name="mode" value="select" checked>select records (can specify id)<br />
<input type="radio" name="mode" value="insert">insert 1 record (must specify all)<br />
<input type="radio" name="mode" value="delete">delete records (must specify id)<br />
<input type="radio" name="mode" value="drop"><i>drop table</i><br />
</p>
<p>Id: <input type="text" name="id" size=32 maxlength=32 /> (32 hex chars)</p>

<p>Latitude: <input type="text" name="lat" size=10 /> (between -90 and 90)</p>
<p>Longitude: <input type="text" name="lng" size=10 /> (between -90 and 90)</p>
<p>Speed: <input type="text" name="spd" size=10 /> (not negative)</p>
<p><input type="submit" value="OK" /></p>
</form>
</body>
</html>
Nick Craver :

You can also wrap your elements without giving them each an ID, since a <label> is implicitly for the input it contains, like this:

<label>
   <input type="radio" name="mode" value="create">
   <i>create table</i>
</label>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to toggle a radio button with a label

how to toggle label's class by clicking radio button. Vanilla JS needed instead of JQuery

Uncheck a checkbox by clicking anywhere on the body and toggle it by clicking its label

How to select radio button by clicking its div?

Force radio button and its label to be on same line

HTML - custom radio button not toggled if clicking the text

clicking text should click the radio button in HTML

Uncheck checked radio button by clicking on label using jQuery

Select radio button on clicking parent div and get its value in angularJS

HTML Radio Button Label - Fill with Javascript ID?

Clicking on a disabled radio button

Clicking on radio button

jQuery toggle radio button

Why radio button is not getting checked by clicking corresponding text is not working in HTML?

HTML text as POST toggle (kinda like a radio button)?

Label for radio button styling

Radio button clicked with label

How to add same border to both input radio button and its label after radio has been checked?

How to toggle fields on clicking a button?

toggle button in listview clicking on itself

How can I bind the value of a radio button in vue.js by clicking on it's label?

Clicking on label not working in HTML

Radio button not clicking on single click

Clicking radio button Selenium/Python

Change the Label of a Radio button on selecting the Radio button

Angular 1 - toggle radio button

Radio toggle button upgrading functionality

Radio buttons do not check when clicking the label

Robotframework - How can I select this type of radio button by means of the text in its associated label?