DropDown Navigation

Discussion in 'JavaScript' started by electron, Jun 24, 2007.

  1. #1
    The following code is not working. Any Suggestions.
    Thanks for your time:)
     
    electron, Jun 24, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this code:
    <!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>
    <title>Drop Down Navigation</title>
    </head>
    <body>
    <form name="form1">
    <select id="list" name="list" onchange="window.location=document.getElementById('list').options[document.getElementById('list').selectedIndex].value">
    <option value="javascript:void(0)">--Goto--</option>
    <option value="http://google.com">Google</option>
    <option value="http://www.yahoo.com">Yahoo</option>
    </select>
    </form>
    
    </body>
    </html>
    HTML:
    i changed the reference to the select element from:
    form1.list
    to:
    getElementById('list')

    and it should be selectedIndex, with a capital I
     
    UnrealEd, Jun 24, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Easier yet:
    
    <select id="list" name="list" onchange="window.location=this.value">
    
    HTML:
    :)
     
    nico_swd, Jun 24, 2007 IP
  4. electron

    electron Well-Known Member

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    Thanks to both of you
     
    electron, Jun 25, 2007 IP