Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Location
    New Jersey
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Location
    New Jersey
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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)....

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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">
    Last edited by Philip M; 02-12-2012 at 07:00 PM.

    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.

  • #5
    New Coder
    Join Date
    Feb 2012
    Location
    England
    Posts
    77
    Thanks
    0
    Thanked 12 Times in 11 Posts
    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.


  •  

    LinkBacks (?)


    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •