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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    code html linking

    Iím looking for a certain script.

    On a page there is a text input field where the user can put a given code in. That code is linked to an html link. When a user puts the given code in, and presses a submitbutton, she is automaticly directed to the htmllink in a blank page.

    In the html file there must be a easy way to edit the list below and the ability to add or remove Code/htmllinks:

    A Code: HTMLlink
    303033 http://www.link.com/link1
    102222 http://www.link.com/link2
    440000 http://www.link.com/link3

    Does anyone know a script or how to do this?

    Thank you in advance,

    Jan

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Location
    Here
    Posts
    3,619
    Thanks
    58
    Thanked 662 Times in 657 Posts
    it would seem to make more sense to me to make it a select box (to avoid people misentering the code), but then maybe you want to keep the options "secret" (which they won't be with javascript/html, but anyway...). here are both approaches - you can see which you like:

    Code:
    <html>
    <head>
    <title></title>
    
    <script type="text/javascript">
    
    function reDirect(choice){
    
    switch (choice){
    case "303033":
    window.open("http://www.google.com")
    break;
    case "102222":
    window.open("http://www.yahoo.com")
    break;
    case "440000":
    window.open("http://www.codingforums.com")
    break;
    }
    
    }
    </script>
    </head>
    <body>
    <select onchange="reDirect(this.value)">
    <option >select code</option>
    <option value="303033">303033</option>
    <option value="102222">102222</option>
    <option value="440000">440000</option>
    </select>
    
    Input code: <input id="tb" type="text"/><input type="button" value="go to page" onclick="reDirect(document.getElementById('tb').value)"/>
    </body>
    </html>

  3. Users who have thanked xelawho for this post:

    janvw3333 (01-03-2012)

  4. #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Xelawho,

    Thanks for the reply, it is very usefull.

    greetings,
    Jan


 

Posting Permissions

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