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
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post

    How do I redirect the page with selection box thing?

    Hello..

    How do I go about making one of those selection boxes where when the user selects a different value it redirects the page to another URL, also can you make it stay on the page also depending on what they select?

    Thanks!

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's one way:
    Code:
    <body>
    <script type="text/javascript">
    function redirect(val)
    {
    	if(val == "void")
    		return false;
    	var loc = String(location);
    	val.substr(0, 1) == "#" 
    		? location = loc.substring(0, loc.lastIndexOf("#")) + val 
    		: location = val;
    }
    </script>
    <select onchange="redirect(options[selectedIndex].value)">
    <option selected value="void">[none]</option>
    <option value="#heading1">H1</option>
    <option value="#heading2">H2</option>
    <option value="http://google.com/">Google</option>
    </select>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <h1 id="heading1">Heading #1</h1>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br>
    <h2 id="heading2">Heading #2</h2>
    </body>
    *this message will self destruct in n-seconds*

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Thanks... I'll give it a try!


  •  

    Posting Permissions

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