0
How to make two separated group of radiobutton when making a form?
for example, class: vvip or vip gender: male or female
3 Respuestas
+ 10
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="class" value="vip" checked>vip<br>
<input type="radio" name="class" value="vvip">vvip
0
Use name attribute for grouping the radio buttons
Example :
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
0
A "group" of radio buttons is defined because they have the same "name". You can put as many radio buttons you want in your "form". You just have to define your different groups by giving the same "name" to the button you want in the same group.
ValentinHacker gave a good example:
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="class" value="vip" checked>vip<br>
<input type="radio" name="class" value="vvip">vvip
The two first button will form the first group because they both have name="gender" and the last two will form another group because their name="class".