PDA

View Full Version : Accept Guidelines


DisVallHear
18-08-2005, 19:52/07:52PM
I need to make a form that has a checkbox that has to be checked before they are allowed to submit the form. (I have got the rest of the form down ok I think).

I am using Dreamweaver and it is new to me. Yes, I know that you hard coders are laughing, but it is a step up from the FP I was using.

I have just started with PHP and as of yet do not know much. And help anyone can offer would be appreciated. Please remember that I am really new at this, so please be specific.

a12c4magic
18-08-2005, 20:01/08:01PM
I have no idea how to achieve this, however if you do a search on google for “checkbox that has to be checked using dreamweaver”
it brings up a fair few useful tutorials.

chrishirst
19-08-2005, 05:31/05:31AM
I usually simply disable the submit button until the checkbox is checked.
Javascript code;
<script type="text/javascript">
function KillSubmit() {
document.forms['form_name'].elements['btn_submit'].disabled = true;
}
function Agreed() {
if (document.forms['form_name'].elements['chk_agree'].checked == true) {
document.forms['form_name'].elements['btn_submit'].disabled = false;
} else {
document.forms['form_name'].elements['btn_submit'].disabled = true;
}
}
</script>

HTML code;
<body onLoad="KillSubmit()">
<form name="form_name" action="" method="post" >
<input type="checkbox" id="chk_agree" name="chk_agree" onClick="Agreed()">Accept?
<input type="submit" name="btn_submit" id="btn_submit" value="submit">
</form>
</body>

Using the KillSubmit() function in the onload will also make sure that anyone with javascript disabled will be able to see the submit button.