Link to home
Create AccountLog in
Avatar of rdavidc
rdavidc

asked on

Simple Checkbox redirect after, "I Agree"

I have a simple checkbox script that I need re-directed to "register.php" when the box is checked and the I Agree button is clicked.

Here is the code.  How do I do this?

Dave
<script type="text/javascript">
 
function AuthorizeValidation(myform) {
 
if(myform.iagree.checked == true) {myform.validation.disabled = false }
 
if(myform.iagree.checked == false) {myform.validation.disabled = true }
 
}
 
</script> 
 
</head>
<body>
<form action="" methed="post" name="myform">
 
<p><input type="checkbox" name="iagree" value="valeur" onClick="AuthorizeValidation(this.form)" /> I agree with general terms and conditions</p>
 
 
 
<p><input type="submit" name="validation" value="I Agree" disabled /></p>
 
</form>

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

Here you go:
<script type="text/javascript">
 
function AuthorizeValidation(myform) {
 
if(myform.iagree.checked == true) {myform.validation.disabled = false }
 
if(myform.iagree.checked == false) {myform.validation.disabled = true }
 
}
 function redirect()
 {
 	if(document.myform.iagree.checked)
	{
		document.myform.action="register.php";
		document.myform.submit();
	}
 }
</script> 
 
</head>
<body>
<form action="" methed="post" name="myform">
 
<p><input type="checkbox" name="iagree" value="valeur" onClick="AuthorizeValidation(document.myform)" /> I agree with general terms and conditions</p>
 
 
 
<p><input type="submit" name="validation" value="I Agree" disabled onclick="redirect()"/></p>
 
</form>

Open in new window

One other option would be to just enter the name of the page e.g. register in the action attribute of the form, i.e. <form action="register.php"

The button to submit is only enabled if they checked the iagree checkbox so that would be one simple solution.
Avatar of rdavidc
rdavidc

ASKER

I thought that I said SIMPLE.  <smile>

It appears that neither solution works.  

Lord of Ports:  Your solution is posted at:  

http://www.shepherdscarebiblecollege.org/Students_Portal/form_checkbox_validation.htm

When I check the box, the I Agree box does not change to allow me to click it.  
Well this definitely works:

<script type="text/javascript">
 
function AuthorizeValidation(myform) {
 
if(myform.iagree.checked == true) {myform.validation.disabled = false }
 
if(myform.iagree.checked == false) {myform.validation.disabled = true }
 
}
 
</script>
 
</head>
<body>
<form action="register.php" methed="post" name="myform">
 
<p><input type="checkbox" name="iagree" value="valeur" onClick="AuthorizeValidation(this.form)" /> I agree with general terms and conditions</p>
 
 
 
<p><input type="submit" name="validation" value="I Agree" disabled /></p>
 
</form>
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rdavidc

ASKER

Ok Here is the deal.

I liked both..... and I am using hielo: only because I already had everything typed in.  Sorry

So, I am going to split the points to each of you.  Because they both worked and are great examples.

I am also going to open a new question for an additional 500 points.  The reason I asked this question is because I could not figure out how to add the Terms of Agreement and Privacy Policy statement on the Register Form so, I split them up.  If it can't be done, then I at least have this one.

If you view this, check and click and you can see the register.php that I am working on.
http://www.shepherdscarebiblecollege.org/Students_Portal/form_checkbox_validationE.htm

Thanks
Avatar of rdavidc

ASKER

the new subject will be in php:  Incorporating a TOA and PP statements into a form