Reputation: 3272
This is short part of my code which display radio buttons.
<table width="100%">
<tr>
<td style="text-align:center">
<input type="radio" name="ah" value="" id="ah" align="left" checked="checked" />AH
</td>
<td style="text-align:center">
<input type="radio" name="esp" value="none" id="esp" align="right"/>ESP
</td>
</tr>
</table>
The problem is that the one radio button (AH) is by default checked as mentioned here and when i click on other radio button it also gets checked but now both are checked how would I disable them. I think it should happen automatically when I click on one radio button other button should be disabled automatically. please correct me where am I wrong???
Upvotes: 0
Views: 276
Reputation: 219920
To group radio buttons together, they should share the same name
:
<table width="100%">
<tr>
<td style="text-align:center">
<input type="radio" name="someName" value="AH" id="ah" align="left" checked="checked" />AH
</td>
<td style="text-align:center">
<input type="radio" name="someName" value="ESP" id="esp" align="right"/>ESP
</td>
</tr>
</table>
Upvotes: 6
Reputation: 35
try this it will help.... you have to give the same name to both radio button
<table width="100%">
<tr>
<td style="text-align:center">
<input type="radio" name="esp" value="" id="ah" align="left" checked="checked" />AH
</td>
<td style="text-align:center">
<input type="radio" name="esp" value="none" id="esp" align="right"/>ESP
</td>
</tr>
</table>
Upvotes: 1
Reputation: 449385
You need to give both radio buttons the same name
attribute so the browser can recognize them as being in the same group.
Upvotes: 2