S
shortbackandsides.no
Here's a working code fragment out of a form.
One checkbox is checked the other isn't.
When you change the status of one the other changes too.
<input type="checkbox" name="nlbox1" value="9" checked
onClick="document.signup.nlbox2.checked=!document.signup.nlbox2.checked;">
<input type="checkbox" name="nlbox2" value="8"
onClick="document.signup.nlbox1.checked=!document.signup.nlbox1.checked;">
OK now the problem (and I expect you are asking, why not just use
radio buttons?)
The form gets sent to someone else's script on a server I can't
modify. Their version of the form looked like this:
<input type="checkbox" name="nlbox[1]" value="9" >
<input type="checkbox" name="nlbox[2]" value="8">
That allowed neither or both boxes to be checked. The problem is if I
try to use:
<input type="checkbox" name="nlbox[1]" value="9" checked
onClick="document.signup.nlbox[2].checked=!document.signup.nlbox[2].checked;">
<input type="checkbox" name="nlbox[2]" value="8"
onClick="document.signup.nlbox[1].checked=!document.signup.nlbox[1].checked;">
I get an error. Mozilla says:
document.signup.nlbox has no properties
MSIE says:
document.signup.nlbox.1 is null or not an object
Any ideas?
Incidentally
<input type="radio" name="nlbox[1]" value="9" >
<input type="radio" name="nlbox[2]" value="8">
won't work because as the name differs they don't operate as a pair.
One checkbox is checked the other isn't.
When you change the status of one the other changes too.
<input type="checkbox" name="nlbox1" value="9" checked
onClick="document.signup.nlbox2.checked=!document.signup.nlbox2.checked;">
<input type="checkbox" name="nlbox2" value="8"
onClick="document.signup.nlbox1.checked=!document.signup.nlbox1.checked;">
OK now the problem (and I expect you are asking, why not just use
radio buttons?)
The form gets sent to someone else's script on a server I can't
modify. Their version of the form looked like this:
<input type="checkbox" name="nlbox[1]" value="9" >
<input type="checkbox" name="nlbox[2]" value="8">
That allowed neither or both boxes to be checked. The problem is if I
try to use:
<input type="checkbox" name="nlbox[1]" value="9" checked
onClick="document.signup.nlbox[2].checked=!document.signup.nlbox[2].checked;">
<input type="checkbox" name="nlbox[2]" value="8"
onClick="document.signup.nlbox[1].checked=!document.signup.nlbox[1].checked;">
I get an error. Mozilla says:
document.signup.nlbox has no properties
MSIE says:
document.signup.nlbox.1 is null or not an object
Any ideas?
Incidentally
<input type="radio" name="nlbox[1]" value="9" >
<input type="radio" name="nlbox[2]" value="8">
won't work because as the name differs they don't operate as a pair.