Changing values of hidden fields from checkboxes
Posted: Wed Jul 05, 2006 4:09 pm
I have a checkbox and hidden field within a form :
So, basically I'm changing the value of the hidden form from the checkbox onClick...Which is fine...But I also want when you click the checkbox again (to untick it) the hidden field reverts back to it's old value.
So I want if you click the checkbox first to tick it, the hidden1 value is put to 1. Then if you click that same checkbox again to untick it, I want the hidden1 value changed back to 0.
How do I do it?
Thanks
Code: Select all
<input name="checkbox1" id="checkbox1" type="checkbox" value="abc" onClick="document.forms[0].hidden1.value = '1'>
<input name="hidden1" id="hidden1" type="hidden" value="0">So I want if you click the checkbox first to tick it, the hidden1 value is put to 1. Then if you click that same checkbox again to untick it, I want the hidden1 value changed back to 0.
How do I do it?
Thanks