View Full Version : Checkbox
florida
05-22-2003, 01:15 PM
For a checkbox how can I make it check automatically when I exit the form?
function checkButton
{
var e1;
if (!e1.checked)
{
return true;
//how do I put a check in the check box here?
}
}
<input type="checkbox" name="fieldhere">
to check the box use...
document.form.checkbox.checked=true;
cheesebagpipe
05-22-2003, 03:33 PM
Assuming 'exit the form' means submitting it:
<form..................onsubmit="fieldhere.checked=true">
florida
05-22-2003, 05:02 PM
Thanks that works great with onsubmit but I think I need to get it to work with body onload.
I tried this:
<body onunload="review.checked=true">
and it did not work.
I want this box to get checked when someone closes/exits the page or goes to another page.
cheesebagpipe
05-22-2003, 05:09 PM
If you're not programming it from 'inside' the form, you'll need to use a fully-qualified reference (document.forms[0].review) or, better:
<body onunload="document.getElementById('review').checked=true">
<input type="checkbox" name="review" id="review">
Not sure why you'd be doing this, though, since the data isn't being submitted.
florida
05-22-2003, 05:51 PM
Thanks again!!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.