Click to See Complete Forum and Search --> : Tick box energising 'submit' button
Hutchball
11-26-2002, 07:50 AM
Hi, is it possible to incluse a tick box on a html form which then 'energises' the 'Submit' button?
E.g. I have a form which i want people to read and agree (via a tick-box) to a disclaimer before the submit button on the form is energised.
Rodders
11-26-2002, 08:06 AM
Something like.....
<FORM NAME=myform>
Agree? <INPUT TYPE=CHECKBOX onClick="document.myform.submit();">
</FORM>
Hutchball
11-26-2002, 08:21 AM
That works, thanks, but its just a tick box which submits. Is it possible to have a 'locked' submit button which unlocks when the box is ticked?
Rodders
11-26-2002, 08:26 AM
<FORM NAME=myform>
Agree? <INPUT TYPE=CHECKBOX onClick="document.myform.btnSubmit.disabled = false;">
<INPUT TYPE=SUBMIT NAME=btnSubmit DISABLED>
</FORM>
EDIT: You might want to add further code to disable the button again if the user unticks the box.
Hutchball
11-26-2002, 11:13 AM
Thanks Rodders. Thats working great. You couldn't help us with the code to re-disable it again? Please?
Hutchball
11-27-2002, 08:27 AM
Can anybody help?
Rodders
11-27-2002, 08:40 AM
<SCRIPT TYPE='text/javascript'>
function switchbutton() {
if (document.myform.btnSubmit.disabled) {
document.myform.btnSubmit.disabled = false;}
else {
document.myform.btnSubmit.disabled = true;}
return true;
}
</SCRIPT>
<FORM NAME=myform>
Agree? <INPUT TYPE=CHECKBOX onClick="return switchbutton();">
<INPUT TYPE=SUBMIT NAME=btnSubmit DISABLED>
</FORM>
Hutchball
11-28-2002, 06:46 AM
That works a treat, thanks mate. :)