Sharon's Script

Created - June, 2004 -

I created this for my friend Sharon. She wanted a script to control check boxes on a form.

If you select the option 'n/a', the 'red' and 'blue' checkboxes are cleared and disabled.
If you de-select the 'n/a' option, the 'red' and 'blue' checkboxes are enabled.



here is the code:

   - this is the script, place it in the head of your document.

function checkSelected() {

//alert('in the function');

if(document.f1.color[0].checked == true){

//alert('n/a is checked');

document.f1.color[1].checked = false;
document.f1.color[1].disabled = true;
document.f1.color[2].checked = false;
document.f1.color[2].disabled = true;


else {

document.f1.color[1].disabled = false;
document.f1.color[2].disabled = false;



   - this is the form section, call the function from the checkbox that will disable the other two if selected.

<form name="f1">

<input type="checkbox" name ="color" value="0" onClick="checkSelected();"> n/a<br>
<input type="checkbox" name ="color" value="1"> red<br>
<input type="checkbox" name ="color" value="2"> blue<br>