program a set of radio buttons to automatically fill in
Posted: Thu Nov 17, 2011 3:18 pm
hi all, i have the following form:
sorry for the lengthy code because of the table.
what i want to do is, if the user clicks No for for any input (p1 through p5), then I want all the other inputs below to automatically fill in with No as well. Similarly, if the user clicks Yes for any answer, I want all the inputs above that answer to fill in with Yes.
i think those are the only two rules i would have to program to ensure that the user provides consistent answers.
thanks!
~p
Code: Select all
<form id="form1" name="form1" method="post" action="results.php">
<table width="680" border="0" align="center" cellpadding="5" cellspacing="5">
<tr>
<td colspan="5"><strong>How much would you pay for X? </strong></td>
</tr>
<tr>
<td width="100"><div align="center">$1</div></td>
<td width="125"><div align="center"><span class="style13">
<input name="p1" type="radio" value="yes" />
</span></div></td>
<td width="125"><div align="center">Yes</div></td>
<td width="125"><div align="center"><span class="style13">
<input name="p1" type="radio" value="no" />
</span></div></td>
<td width="125"><div align="center">No</div></td>
</tr>
<tr>
<td><div align="center">$2</div></td>
<td><div align="center"><span class="style13">
<input name="p2" type="radio" value="yes" />
</span></div></td>
<td><div align="center">Yes</div></td>
<td><div align="center"><span class="style13">
<input name="p2" type="radio" value="no" />
</span></div></td>
<td><div align="center">No</div></td>
</tr>
<tr>
<td><div align="center">$3</div></td>
<td><div align="center"><span class="style13">
<input name="p3" type="radio" value="yes" />
</span></div></td>
<td><div align="center">Yes</div></td>
<td><div align="center"><span class="style13">
<input name="p3" type="radio" value="no" />
</span></div></td>
<td><div align="center">No</div></td>
</tr>
<tr>
<td><div align="center">$4</div></td>
<td><div align="center"><span class="style13">
<input name="p4" type="radio" value="yes" />
</span></div></td>
<td><div align="center">Yes</div></td>
<td><div align="center"><span class="style13">
<input name="p4" type="radio" value="no" />
</span></div></td>
<td><div align="center">No</div></td>
</tr>
<tr>
<td><div align="center">$5</div></td>
<td><div align="center"><span class="style13">
<input name="p5" type="radio" value="yes" />
</span></div></td>
<td><div align="center">Yes</div></td>
<td><div align="center"><span class="style13">
<input name="p5" type="radio" value="no" />
</span></div></td>
<td><div align="center">No</div></td>
</tr>
</table> </form>
what i want to do is, if the user clicks No for for any input (p1 through p5), then I want all the other inputs below to automatically fill in with No as well. Similarly, if the user clicks Yes for any answer, I want all the inputs above that answer to fill in with Yes.
i think those are the only two rules i would have to program to ensure that the user provides consistent answers.
thanks!
~p