Introduction To Javascript
More With Forms
Checkboxes
Checkboxes are square boxes which can be clicked on or off. The following HTML produces a checkbox.
<input type="checkbox" name="myCheckBox">
You find out whether a checkbox is clicked by using the following command.
if(document.myForm.myCheckBox.checked) {
code to run
}
Radio Buttons
Radio buttons are groups of circular buttons of which only one can be selected. The following HTML produces a pair of radio buttons.
<input type = "radio" name="radio1">
<input type = "radio" name="radio1">
You find out whether a radio button is clicked by using the following command.
if(document.myForm.radio1[0].checked) {
code to run
}
This checks to see if the first option has been clicked. You would need to include an if to check the second option.