Results 1 to 4 of 4

Thread: On click redirection from form and external index

  1. #1
    Join Date
    Dec 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question On click redirection from form and external index

    Hello,

    I found this thread here

    And I am wanting something just a little different.

    The code I have is as follows
    Code:
    <head>
    <script type="text/javascript" src="num.js"></script>
    </head>
    
    <body>
    
    <form action="" method="get" onsubmit="this.action = 'http://www.graceservicesgroup.com/' + this.elements['code'].value.toLowerCase() + '.html'; return true;">
    <fieldset>
    <legend>Code entry form</legend>
    <input type="text" name="code" id="code" size="15">
    <label for="code">Enter Code:</label>
    <input type="submit" value="Submit">
    </fieldset>
    </form>
    
    </body>
    This is just the example code from the thread above with my own url as well as my script.

    What I am looking to do is take the form data and compare it to a javascript that contains the links and their code. Then have the link associated with the form entry to be returned and then redirect to the returned link.

    The desired output is that if 0 is entered and submitted it will redirect the user to http://support.graceservicesgroup.com/
    And other numbers to other places, such as the homepage or a promotional page.

    Any assistance is greatly appreciated!
    Last edited by whoknowswhat; 12-23-2007 at 02:04 AM.

  2. #2
    Join Date
    Dec 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Please, any help at all will be appreciated, I have no idea where to start or what I should use to make the redirection index or how I would make it, even pointers would help

    How would I use the form data to look up the number in the index
    How would I return the string from the index to redirect the window to the desired link

    I just need some pointers

    Thanks in advance

    Edit:

    num.js
    Code:
    if (num=="0")
     document.location="http://www.graceservicesgroup.com/support.html";
    Last edited by whoknowswhat; 12-23-2007 at 01:59 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    .script {
    display:none;
    }
    </style>
    <script type="text/javascript">
    function gotoit(num){
    if (num=="0")
     window.location="http://www.graceservicesgroup.com/support.html";
    }
    document.write('<style type="text/css">.noscript {display:none;}.script{display:block;}<\/style>');
    </script>
    </head>
    <body>
    <div class="script">
    <form action="#" onsubmit="gotoit(this.elements[0].value);return false;">
    <div><input type="text">
    <input type="submit" value="Go">
    </div></form>
    Enter 0 for Support
    </div>
    <div class="noscript">
    <a href="http://www.graceservicesgroup.com/support.html">Support</a>
    </div>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Dec 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, That is just like I needed. I even got the javascript in a .js file to hold all the locations in to work from that!

    num.js:
    Code:
    function gotoit(num){
    if (num=="0")
     window.location="http://www.graceservicesgroup.com/support.html";
    if (num=="01")
     window.location="http://www.graceservicesgroup.com/flash/";
    }
    document.write('<style type="text/css">.noscript {display:none;}.script{display:block;}<\/style>');
    testnum.html:
    Code:
    <head>
    
    <script type="text/javascript" src="num.js"></script>
    
    </head>
    
    
    <body>
    
    <div class="script">
    <form action="#" onsubmit="gotoit(this.elements[0].value);return false;">
    <div><input type="text">
    <input type="submit" value="Go">
    </div></form>
    Enter 0 for Support
    </div>
    <div class="noscript">
    <a href="http://www.graceservicesgroup.com/support.html">Support</a>
    </div>
    
    </body>
    Thanks for all your help!

Bookmarks

Posting Permissions

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