T
Trevor L.
I have this code
<form action="" id="form1" name="form1">
Please answer yes or no <br/>
<input type="checkbox" id="yes" name="yes" />Yes <br/>
<input type="checkbox" id="no" name="no" />No <br/>
<input type="button" value="Send" onclick="sendmess()" />
</form>
This results in this being displayed
Please answer yes or no
Yes
No
No matter whether I tick or don't tick either box, the value returned is on.
e.g. I have a function:
function sendmess()
{
alert ('YES ' + document.forms['form1'].elements['yes'].value +
' NO ' + document.forms['form1'].elements['no'].value )
return
}
On clicking Send, all of these return the same result
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
The result is an alert:
YES no NO on
How do I test which box has been ticked ?
<form action="" id="form1" name="form1">
Please answer yes or no <br/>
<input type="checkbox" id="yes" name="yes" />Yes <br/>
<input type="checkbox" id="no" name="no" />No <br/>
<input type="button" value="Send" onclick="sendmess()" />
</form>
This results in this being displayed
Please answer yes or no
Yes
No
No matter whether I tick or don't tick either box, the value returned is on.
e.g. I have a function:
function sendmess()
{
alert ('YES ' + document.forms['form1'].elements['yes'].value +
' NO ' + document.forms['form1'].elements['no'].value )
return
}
On clicking Send, all of these return the same result
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
The result is an alert:
YES no NO on
How do I test which box has been ticked ?