My question is, what is the opposite of this function?
That is what is the JavaScript call when a Checkbox is unselected?
So that we can call a suitable function when a selected Checkbox is unselected?
so you would think this would be the JavaScript unselect command:
You ARE calling it from within the onclick. I’d have to see your “set_border_red” function. You’re passing the ID, it looks like. The function should check the checked status and set the border based upon that.
This is not working!
That is after I replace function set_border_red with above Code of yours now the border is not set to Red upon a checkbox being selected!
No.
The id sent is the id of the DIV that is around this input.
So are you saying that reason that that code did not work is because we need to include an id in each Input tag and send that for being checked?
I see your point.
Yes… the element that you are trying to style is the ID that needs to be passed to the function. You could do div.child, but that would be an extra step.
or have unnecessary characters on the end of the test
if(document.getElementById(item).checked)
Thesing == true is pointless as the value you are comparing it to will be converted to true or false if you omit that comparison. Only if you don’t want the other value converted to true or false and want to test if it is alreeady true or false is it worth comparing it to true and then you need === in order to do an exact comparison without a conversion.
Similarly == false is also pointless as you can achieve the same result using ! on the front of the other value instead.