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
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    go to a different page depending on input in form

    I have a form and when it is submitted I would like the action to take the user to two different pages depending on what the input was. Example if the user enters a number less than 10 then to page 1 if between 10 and 19 page 2 and if above 20 page 3 and so on.

    Can this be done, I need to be pointed to a tutorial or similar as I am a serious newbie. Is Javascript what I am looking for. I am using PHP.

    Also, if not too much to ask, should I also still be able to pass parameters to the next page.

    Thanks in Advance

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    How about posting the data to a single predefined page and execute the code based on the posted data?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    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
    Here you are:-

    Code:
    <input type = "text" name = "box1" id = "box1" size = "2" maxlength = "2" onblur = "checkit(this)"></br>
    
    <script type = "text/javascript">
    
    function checkit(which) {
    x = which.value;
    if (!/\d{1,2}/.test(x)) {
    alert ("You must enter a one or two-digit number  ");
    which.value = "";
    which.focus;
    return false
    }
    if (x >= 20) {window.location.href = "page3.html"}  // note start with highest number and work down
    else if (x >= 10) {window.location.href = "page2.html"}
    else {window.location = "page1.html"}
    } 
    
    </script>

    BTW, the time to say "thanks" is afterwards, not beforehand which gives the impression that you take other people's unpaid assistance for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.

  • #4
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the etiquette advice. Makes since, I just wanted to express that I would be grateful for any input given, as I know that people take their free/ personal time to write responses. Of course I did not intend to be rude.

    Further, thanks for the code advice. I will go work on it right away.

    Thanks

  • #5
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the above code.

    I can not figure out how to incorporate this into a form. I am looking to pass values from the form into the next web pages based on a calculation from information input into that cell.

    Any ideas, please?


  •  

    Posting Permissions

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