I’ve got a form in which the user can give a rating from 1 to 5, this is done through radio boxes. But without check the user can click on the same button multiple times how do I prevent this?
the code is simply written
echo "<input type='hidden' name='risk' />
<td>1<input type='radio' name='question[]' id=1 value=1 onclick='calculate_score(".$number.",this.value)'/></td>
<td>2<input type='radio' name='question[]' id=2 value=2 onclick='calculate_score(".$number.",this.value)'/></td>
<td>3<input type='radio' name='question[]' id=3 value=3 onclick='calculate_score(".$number.",this.value)'/></td>
<td>4<input type='radio' name='question[]' id=4 value=4 onclick='calculate_score(".$number.",this.value)'/></td>
<td>5<input type='radio' name='question[]' id=5 value=5 onclick='calculate_score(".$number.",this.value)'/></td>
</table></form>";
could anyone tell me how to handle this?
note that the code above is only a snip it from the code and it does actually work. it’s purely functional. As you can see once this radio box is clicked it goes to a javascript function do I build the check there and how would I go about something like that?
You need to write the
calculate_score()function so that it calculates according to the status of user selections, not according to the action of checking or unchecking a button. It would be bad usability and bad functionality to prevent the user from changing his selection (except perhaps in a special game or test).