Javascript ??
- Started
- Last post
- 8 Responses
- jobhall
How would I make a check box that, when if it is checked, it greys out a certain area on my page?
- mitsu0
fnCheckBox()
{
if(mychkbox.checked=true)
{
fnHackersOfWrldUnite()
}
}type='checkbox'
id='mychkbox'
onchange='fnCheckBox'
- mike0
how do you mean grayed out?
I think mitsu's code is going to leave you more frustrated than enlightened... he isn't checking the value of the checkbox he is reassigning it... the checked property returns true or false, it can also be assigned however. also the onchange event handler should not be used for a checkbox, you should use onclick.
I've put a sample of this up so you can grab that if you like. the script will alert the state of the checkbox when it is clicked.
hope this helps...
- gabe0
we love you mike!
and i'm out
- mitsu0
heh, oops i did assign it! sorry, i was too preoccupied with tabbing those lines, which proved to be useless... ahh, well
- mitsu0
also, in my defense:
"also the onchange event handler should not be used for a checkbox, you should use onclick. "
that's subjective. i've had to use both in applications that i've written before in just one checkbox tag, but whatever. just depends on the behavior you're looking for.
- mike0
it is not subjective mitsu, the onchange event handler is NOT supported for the checkbox object.
to put it in a more caustic manner... RTFM
http://developer.netscape.com/do…
- mitsu0
"it is not subjective mitsu, the onchange event handler is NOT supported for the checkbox object."
omg, mike... how long have you been coding?
F the manual:
- mike0
christ mitsu, this is ridiculous... in my browser, IE6 PC I have to check the box, then click off on the page somewhere in order for the event handler to get called... it is NOT SUPPORTED! Just because it works on your specific browser and platform doesn't make it proper...
Look at the docs man... why are you trying to argue the API?