Click to See Complete Forum and Search --> : radio buttons or check boxes???
Hello all,
I have to develop a usability survey for a website. Some of the questions are supposed to allow the user to choose more then one answer thus calling for checkboxes. Other questions are allowed only one answer, requiring radio buttons, correct? This is the dilemma - we want the survey to appear consistent, instead of every other question being a radio button. Is there a way to use checkboxes but, with certain questions, only allow one selection? Or, is there a way to allow more then one radio button to be checked off? If neither is possible, any ideas on how I develop a consistent looking survey?
Thank you all for suggestions.
Zach Elfers
12-04-2002, 02:23 PM
The only way radio buttons are only able to have one check is because the sets all have the same name:
<input type="radio" name="radioset">
<input type="radio" name="radioset">
<input type="radio" name="radioset">
In the above example, you would only be able to check ONE of the radio buttons because they all have the same name. If you want the user to be able to check more then one:
<input type="radio" name="1">
<input type="radio" name="2">
<input type="radio" name="3">
:)
Thank, Zach, for your reply. I know that with a different names radio buttons will allow more then one to be selected. But that would throw our db off, all of the selections for question 1 would have to have the same name, thus not allowing more then one radio button to be checked.
It there a way, possibly with check boxes, that would
not allow a user to select more then one for a given question. Even if that means an alert appearing when the user makes the second selection, asking the user to make only one selection and, if possible, deleting the second selection that was made. (sorry for the runon)
Thanks, again, I appreciate the help!
Zach Elfers
12-04-2002, 02:35 PM
I guess you'll have to use checkboxes then because I don't think that is possible with radio buttons. You might also be able to edit your script to work with radio buttons, but that might be a lot of work.
Any ideas on how to accomplish this with check boxes?
Zach Elfers
12-04-2002, 02:52 PM
You might just substitute checkboxes for radio buttons. Instead of <input type="radio" change it to <input type="checkbox". I don't know if that is what you are looking for though.
No, because then users will always be able to check more then one. There are about three questions in which I want the user to make only one selection. And it has to look consistent, either all check boxes or all radio buttons.
err :(
Okay, it's something like this, now if only I could get it working in Netscape...:
<html>
<heaD>
<script language="JavaScript">
<!--
function checkOne(elem){
var nm = elem.name;
var cnt = document.getElementsByName(nm).length;
for(var i = 0;i<cnt;i++){
document.getElementsByName(nm)[i].checked=false;
}
elem.checked = true;
}
//-->
</script>
</head>
<body>
Only Select One:<br>
Yes <input type="checkbox" name="group_1" onClick="checkOne(this);"><br>
No <input type="checkbox" name="group_1" onClick="checkOne(this);"><br>
Maybe <input type="checkbox" name="group_1" onClick="checkOne(this);"><br>
<br>
Select All That Apply:<br>
Blue <input type="checkbox" name="group_color"><br>
Red <input type="checkbox" name="group_color"><br>
Purple <input type="checkbox" name="group_color"><br>
<br>
</body>
</html>
gil davis
12-04-2002, 03:50 PM
Originally posted by Soti
now if only I could get it working in Netscape...:
Enclose the form elements in a <FORM></FORM> tag (like you are supposed to), and Netscape will work.