I am trying to make a questionare table. However, the radio inputs arn't exclusive when selecting (I am able to select both and unable to deselect)
<fieldset>
<legend>test form</legend>
<table>
<tr>
<th></th>
<th>Yes</th>
<th>No</th>
</tr>
<tr>
<th>test question?</th>
<form>
<td><input id="yes1" type="radio"></td>
<td><input id="no1" type="radio"></td>
</form>
</tr>
</table>
</fieldset>
Is there a fix to this and, if so, how do I fix it?
I expected that since I put the td elements nested in the form element it would solve the problem. But it never did.
CodePudding user response:
The problem is that you need them to share that same 'name' attribute so HTML will know that they are connected
<td><input id="yes1" name="1" type="radio"></td>
<td><input id="no1" name="1" type="radio"></td>