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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    San Antonio, TX
    Posts
    131
    Thanks
    1
    Thanked 0 Times in 0 Posts

    need help with a submission form

    What I am wanting is this...once the user checks the box, and clicks submit...the prompt comes up with an 'OK' button. I want the user to be redirected to "\page1.html" when they click that 'OK' button. What do I need to do, or what do I need to change in my code???

    Below is the code I am using:

    <html><title>agreement form</title>
    <P>
    <HEAD>
    <script>
    var checkobj
    function agreesubmit(el){
    checkobj=el
    if (document.all||document.getElementById){
    for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
    var tempobj=checkobj.form.elements[i]
    if(tempobj.type.toLowerCase()=="submit")
    tempobj.disabled=!checkobj.checked
    }
    }
    }
    function defaultagree(el){
    if (window.checkobj&&checkobj.checked)
    alert("Great, Lets get started.")
    else
    alert("Please check the box if your agree to the conditions")
    return false
    }
    </script>
    <BODY BGCOLOR="#00FFFF">
    <form name="agreeform" onSubmit="return defaultagree(this)">
    YOU MUST MEET MY CONDITIONS, WHICH ARE...<br><br>
    <textarea rows="5" name="S1" cols="30" style="width:60%" wrap=virtual>
    1. FIRST CONDITION.
    2. SECOND CONDITION.
    3. THIRD CONDITION.
    4. FOURTH CONDITION.
    5. FIFTH CONDITION.
    6. SIXTH CONDITION.
    7. SEVENTH CONDITION.
    </textarea><p>
    <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">
    <b>Check box if you agree to the above conditions</b><p>
    <input type="Submit" value="Submit!">
    </form>
    <script>
    document.forms.agreeform.agreecheck.checked=false
    </script>
    <p><p>
    </body></head></html>

    Thanks in advance for your help.

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well once you have checked the form validity, just do:
    Code:
    location='page1.html';
    Omnis mico antequam dominus Spookster!

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    San Antonio, TX
    Posts
    131
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thanks, but...

    Thanks, But I am kinda new with Javascript, I apologize for not making that more clear earlier. I copied this script from another website. (using view-source). Where would I put that code location='page1.html'; at within my code? I have tried to put it in several locations, but when I do, it is stopping the rest of the page from working. Also, how do you check the form validity? I am a copy and paste-er and haven't really learned javascript yet, I am getting there though Again, Thanks for your help.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Copy and paste this:
    Code:
    <html>
    <head>
    <title>agreement form</title>
    <script type="text/javascript">
    function agreesubmit(el){
      var tempobj;
      var els=el.form.elements;
      for (var i=0;i<els.length;i++){ //hunt down submit button
        tempobj=els[i];
        if(tempobj.type.toLowerCase()=="submit")
           tempobj.disabled=!el.checked;
      }
    }
    function defaultagree(el){
      if (el.agreecheck.checked){
        alert("Great, Lets get started.");
        location.href='page1.html';	
      }
      else
        alert("Please check the box if your agree to the conditions")
      return false
    }
    </script>
    </head>
    <body>
    <form name="agreeform" onSubmit="return defaultagree(this)">
    <p>YOU MUST MEET MY CONDITIONS, WHICH ARE...</p>
    <textarea rows="5" name="S1" cols="30" style="width:60%" wrap="virtual">
    1. FIRST CONDITION.
    2. SECOND CONDITION.
    3. THIRD CONDITION.
    4. FOURTH CONDITION.
    5. FIFTH CONDITION.
    6. SIXTH CONDITION.
    7. SEVENTH CONDITION.
    </textarea>
    <p>
    <input name="agreecheck" type="checkbox" onClick="agreesubmit(this)" />
    <b>Check box if you agree to the above conditions</b>
    <p><input type="Submit" value="Submit!" disabled="disabled" /></p>
    </form>
    </body>
    </html>
    Last edited by glenngv; 01-28-2005 at 11:00 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Location
    San Antonio, TX
    Posts
    131
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you

    This worked! It is confusing to me however, because I placed the text (location='page1.html' in the exact same location you did, and when I clicked the submit button with the checkbox checked, it would act as if I had not checked the box and bring up the prompt to check the box first. I will go over the code to see what the differences are, but I just wanted to thank you for your help.

    Imperial Spider.

  • #6
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well the reason for that is the syntax of your conditional statement:
    Code:
    if( condition ) {
    do everything between that bracket and the next
    }else{
    or do evereything between that bracket and the next
    }
    It is different without the brackets:
    Code:
    if(condition)
    just do the first thing following the condition
    else
    just do the first thing following the exception
    Not sure if that exactly makes sense to you.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

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