Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

amtjb

macrumors member
Original poster
Jan 5, 2011
46
0
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>
 
Last edited by a moderator:
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.
 
Will someone please tell me how to make my drop down list link to different url?

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>
 
Drop down list

Thanks for the help a million. That is exactly what I was trying to figure how to do.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.