Without changing the format of selectors (ie. radio buttons, checkboxes, etc.) I need to use only checkboxes for this format.. and only one can be selected. What should I add to my code <td>Administrator <input type="checkbox" name="admincheckbox" value="checkbox"> Staff <input type="checkbox" name="staffcheckbox" value="checkbox"></td> </tr> Thats code for the two checkboxes.. is there any syntax used to only allow one checkbox to be selected of the two
The *right* way would be to use radio buttons -- that's way they exist. It also serves as a visual to the end user that 'hey, only 1 of these can be chosen.' Is there some reason that you don't want to do this?
The boss said so, pretty much. Radio buttons IS the easier way, I am aware of that fact. But, for the sake of learning we have to provide code so only one checkbox can be selected.
If you know JS than this will clear it up var checkbox_selected = ""; function CheckIfcheckboxButtonsSelected() { if (checkbox_selected == "") { // Not checked yet } else { alert("sorry, checked already"); } } <INPUT TYPE="checkbox" NAME="chb" onClick="checkbox_selected='SomeValue'">YES <INPUT TYPE="checkbox" NAME="chb" onClick="checkbox_selected='SomeValue'">No <INPUT TYPE="checkbox" NAME="chb" onClick="checkbox_selected='SomeValue'">Maybe <INPUT TYPE="button" VALUE="Check Form Fields" onClick="CheckIfcheckboxButtonsSelected()">
checkbox is meant for multiple selection and radio list is for a single select which is what you're after.