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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    URL in select menu

    Hi.

    I have following code:

    Code:
    <select name="Networksites">
    <option selected="selected">Network Websites</option>
    <option value="http://www.testsite.com">Testsite.com</option>
    <option value="http://www.testsite2.com">Testsite 2.com</option>
    </select>
    I want to be able to navigate to the sites when I select them in the menu, however nothing happens when I select them.

    What have I done wrong? I found an old thread here, and its code looked similiar.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    <select name="Networksites" onchange="window.location=this.value;">
    This will do it partially, but I'm not whether it suits or not since you may have to check this.value.
    PS:Giving a button "GO to the selected" would be more friendly to users.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Sep 2007
    Posts
    34
    Thanks
    0
    Thanked 7 Times in 7 Posts
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function openSite(thisELE)
    {
    var index = thisELE.selectedIndex;

    if(index > 0)
    {
    window.location = thisELE.options[index].value;
    }
    }
    </script>
    </head>

    <body>
    <select name="Networksites" onchange="openSite(this)">
    <option selected="selected">- Select -</option>
    <option value="http://www.testsite.com">Testsite1.com</option>
    <option value="http://www.testsite.com">Testsite.com</option>
    <option value="http://www.testsite2.com">Testsite 2.com</option>
    </select>
    </body>
    </html>

    gud luck
    rams,

  • Users who have thanked rams1703 for this post:

    CaptainB (10-27-2007)

  • #4
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Thanks, that worked!


  •  

    Posting Permissions

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