Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-11-2012, 03:04 PM   PM User | #1
chikquita6
New to the CF scene

 
Join Date: Feb 2012
Location: New Jersey
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chikquita6 is an unknown quantity at this point
Smile Check Box Validation

Hi, I am not familiar with javascript, I am using a check box validation tool that I copied from this site:

http://mediazeal.com/checkbox-validator.htm

This is my webpage:

http://rbhlc.weebly.com/discover-hea...n-jyutsu.html#

Right now when you click the buy now button (when the checkbox is checked) i does not go to the hyperlink. How can I get the button to go to my link when the checkbox is validated?

Here is my code: (the authorize.net account it a Test Account.. so it won't link to anything sensitive)

<form name="form" method="post" action="#" onSubmit="return checkme();">
<table cellpadding="0" cellspacing="0" border="0">

<tr>
<td colspan="2" align="center"><input type="checkbox" name="agree" value="agree_terms"> I agree to the terms</td>
</tr>

<tr>
<td colspan="2" align="center">

<form name="PrePage" method = "post" action = "https://scotest.authorize.net/payment/CatalogPayment.aspx">
<input type = "hidden" name = "LinkId" value ="3569f626-b8a8-4974-8ceb-35ca08a63087" />
<input type = "image" src ="//testcontent.authorize.net/images/buy-now-gold.gif" /> </form>

</td>
</tr>

Thank you for your support.
chikquita6 is offline   Reply With Quote
Old 02-11-2012, 06:31 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,100
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You do not have (or have not posted) a function checkme().

Code:
<form name="myform" method="post" action="#" onSubmit="return checkme();">
<table cellpadding="0" cellspacing="0" border="0">

<tr>
<td colspan="2" align="center"><input type="checkbox" name="agree" value="agree_terms"> I agree to the terms</td>
</tr>
</table>

<input type = "submit" value = "Submit">
</form>

<script type = "text/javascript">

function checkme() {
if (document.myform.agree.checked == false) {
alert ("Checkbox was not checked");
return false;
}
}

</script>
For clarity prefer to name your form "myform" rather than just "form".

Quizmaster: What was the name of the world's first cloned sheep?
Contestant: Shaun
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote
Old 02-12-2012, 04:44 PM   PM User | #3
chikquita6
New to the CF scene

 
Join Date: Feb 2012
Location: New Jersey
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chikquita6 is an unknown quantity at this point
Thank You

Thank you for your reply... what I really would like to know is how you link to another page when you press the submit button (assuming the checkbox is validated)....
chikquita6 is offline   Reply With Quote
Old 02-12-2012, 05:51 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,100
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by chikquita6 View Post
Thank you for your reply... what I really would like to know is how you link to another page when you press the submit button (assuming the checkbox is validated)....
Use Ajax to submit the form. Then onSuccess callback, set window.location.href = new_url.

For more info see:- http://www.mousewhisperer.co.uk/ajax_page.html

Or redirect in your server-side script. The target page that you are submitting to has to do the redirect. It is as simple as passing the redirect value in a hidden form field and calling redirect on the server with that value. <input type=hidden name="hiddenURL" value="http://www.myOtherPage.html">
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 02-12-2012 at 07:00 PM..
Philip M is online now   Reply With Quote
Old 02-12-2012, 06:00 PM   PM User | #5
Co1dFusion
New Coder

 
Join Date: Feb 2012
Location: England
Posts: 77
Thanks: 0
Thanked 12 Times in 11 Posts
Co1dFusion can only hope to improve
Do you want the redirect to hapen after the form is processed on the action page or before.

You could use JavaScript that is called when the sumbit button is clicked, and if "box1"==true then redirect to another page.
Co1dFusion is offline   Reply With Quote
Reply

Bookmarks

Tags
check box, javascript, validator

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:23 AM.


Advertisement
Log in to turn off these ads.