PDA

Click to See Complete Forum and Search --> : checkbox question (HTML)


Aqeel
Jan 10th, 2003, 05:13 AM
i'm not sure if this is the right forum for it. my question is,
how can I disable a checkbox on html page using either css(preferably) or any way. i used 'disabled' attribute. but it greys out the check box. I dont want it to look grey.
and plz be quick.

DeadEyes
Jan 10th, 2003, 05:33 AM
total hack

<input type="checkbox" onclick="this.checked=false">

Aqeel
Jan 10th, 2003, 05:39 AM
great:

i would use:

<input type="checkbox" onclick="this.checked= !this.checked">

DeadEyes
Jan 10th, 2003, 05:50 AM
thats worked out as quite an elegant solution,
but users should have some way of knowing it's disabled and not just click mindlessly.

Rick Bull
Jan 10th, 2003, 07:25 AM
By the way I think you should be able to use the disabled pseudo class (just going from memory, so I'm not sure if I'm right), but I have a suspicion IE won't support it:


input:disabled {
background:white;
color:black;
}


if it isn't in the CSS 2 specs I think it's in 3, but you can use this (again won't work in IE)


input[disabled] {
background:white;
color:black;
}



Which is preferable to JavaScript, as not every has it (10-15%).