Click to See Complete Forum and Search --> : Checkbox Help
Kevin Taylor
07-01-2003, 03:04 PM
I am looking for help or a piece of script that can show me an example of a specific style of checkboxes.
For example.
If a user is presented with a page of options in 3 categories. The user selects one checkbox from the first category, and select others from the second and third category 'gray out' and become unselectable. The second checkbox is selected, and select options from the third checkbox is 'grayed out' leaving only what is available for that specific configuration, able to be selected.
Can this be done?!?
<!-- Untested Code -->
<form action="" name="myForm"><div>
<p>One:<br><input type="checkbox" name="one" onClick="if(this.checked){this.form.two.disabled=true; this.form.three.disabled=true;} else {this.form.two.disabled=false; this.form.three.disabled=false;"></p>
<p>Two:<br><input type="checkbox" name="two" onClick="if(this.checked){this.form.one.disabled=false; this.form.three.disabled=true;} else {this.form.one.disabled=false; this.form.three.disabled=true;}></p>
<p>Three:<br><input type="checkbox" name="three"></p>
</div></form>
[J]ona
Kevin Taylor
07-07-2003, 10:22 AM
Been working on this code all morning, and can't get it to work. I get error's saying the code is looking for an additional }, and when I try to troubleshoot the code, there's no place that we can put that.
Can you elaborate on this a bit more, please? I understand what the code is going to do, and how it will work, but with the error's I cannot isolate the issue and get it to function.
Any additional help will be much apprecaited.
-Kevin
freefall
07-07-2003, 10:50 AM
<form action="" name="myForm"><div>
<p>One:<br><input type="checkbox" name="one" onClick="if(this.checked){this.form.two.disabled=true; this.form.three.disabled=true;} else {this.form.two.disabled=false; this.form.three.disabled=false;}"></p>
<p>Two:<br><input type="checkbox" name="two" onClick="if(this.checked){this.form.one.disabled=false; this.form.three.disabled=true;} else {this.form.one.disabled=false; this.form.three.disabled=true;}"></p>
<p>Three:<br><input type="checkbox" name="three"></p>
</div></form>
It had a missing } and a missing ", before the "></p> in the second line and the ></p> in the third line, respectively.
I don't know if this is how you want it to work... when you check one, 2&3 are disabled, when you uncheck it, 2&3 are enabled. When you check 2, only 3 is disabled, when you uncheck it, 3 remains disabled.
If that's how you want it, cool!
Cheers!
- Ian
Kevin Taylor
07-07-2003, 11:07 AM
That got it, thanks for all the help! =)
-Kevin
My apologies for the typo. Thank you for helping him, freefall.
[J]ona
freefall
07-07-2003, 05:08 PM
It's no problem, I couldn't count how many times I've made simple mistakes like that, no big deal! Sometimes it helps also to have a fresh eye look it over!
- Ian