Drop Down List

Discussion in 'Web Design and Development' started by amtjb, Jan 23, 2015.

  1. amtjb, Jan 23, 2015
    Last edited by a moderator: Jan 23, 2015

    amtjb macrumors member

    Joined:
    Jan 5, 2011
    #1
    Will someone please tell me how to make my drop down list link to different url?

    Code:
    <!DOCTYPE html>
    <html lang=“en”>
    <head>
         <meta charset=“utf-8”/> 
         <title></title>
         <link rel=“stylesheet” href=“style.css” />
    </head>
    <body>
    <label for="Websites">Websites:</label>
    <select id="Websites" name="Websites">
                    <option value="Google">Google</option>
                    <option value="Facebook">Facebook</option>
                    <option value="Twitter">Twitter</option>
                    <option value="Pinterest">Pinterest</option>
            </select>
    
    </body>
    </html>
     
  2. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #2
    We're gonna need just a bit more info if you want any help.

    What exactly are you trying to accomplish?
     
  3. amtjb thread starter macrumors member

    Joined:
    Jan 5, 2011
    #3
    Drop down list

    I want to be able to go to main menu. Click on main menu to go to web page on my website that has drop down list. Once on page that has drop down list. Have information telling person that they must make a selection from drop down list to go to desired web site.
     
  4. 960design macrumors 68000

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #4
    You are misusing form field elements, which is why you are having difficulty. List elements would be more appropriate ( <ul> or <ol> ). A little javascript will make it work.
    Code:
    <select id="websites" name="websites">
    <option value="http://www.google.com">Google</option>
    <option value="http://www.facebook.com">Facebook</option>
    <option value="http://www.twitter.com">Twitter</option>
    <option value="http://www.pinterest.com">Pinterest</option>
    </select>
    <script type="text/javascript">
     var urlmenu = document.getElementById( 'websites' );
     urlmenu.onchange = function() {
          window.open( this.options[ this.selectedIndex ].value );
     };
    </script>
     
  5. amtjb thread starter macrumors member

    Joined:
    Jan 5, 2011
    #5
    Drop down list

    Thanks for the help a million. That is exactly what I was trying to figure how to do.
     

Share This Page