Using onCheck() to "lock" checkboxes

weaponX
weaponX used Ask the Experts™
on
I want to put two columns of checkboxes on a page...

one column labeled "yes", one labeled "no".

I want the "yes" boxes to all be checked...I don't want them to be uncheckable...if you try to uncheck it, I want a blur() or something to occur so the "checked" value is retained.

I want the "no" boxes all unchecked and I don't want them to be checkable.

I am trying somethinglike this...

<form name="checks">
<input type="checkbox" name="box1" onCheck=document.checks.box1.checked = false;>
</form>

or

<form name="checks">
<input CHECKED type="checkbox" name="box1" onCheck=document.checks.box1.checked = true;>
</form>

Obviously this isn't working if I'm here asking you guys...

Anyone up on the lockage of the boxage???

Bueller?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013

Commented:
Checkboxes are kept in the dom as an array so you need to in clude an index to refrerence them that way.  It is better to use:
<input CHECKED type="checkbox" name="box1" onCheck=this.checked = true;>

That way the reference is unambitguous.

Cd&
Commented:
Sorry Cd&... but that doesn't work... hehehe

here it is weaponX:

<input type="checkbox" name="box1" onClick="this.checked = true;" checked>

and:

<input type="checkbox" name="box2" onClick="this.checked = false;">

cheers =0)

Author

Commented:
this place ROCKS...service I tell you.

I appreaciate the effort COBOLsaurus :p

BUT

ivanmata is right across the board.


ivan, take the 20 piece if you want it...I woulda made it worth more but I don't have many points to spend and I don't know many answers to earn more..

thumbsup!!


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial