How to create HTML dropdown list with hyperlink without button

Tag: |   Category:

Paste below HTML code where you want the dropdown

<form name="form1">
<select name="menu1" id="menu1">
<option value="Select Category">Select Category</option>
<option value="http://www.joomla.org">Joomla</option>
<option value="http://www.wordpress.org">WordPress</option>
<option value="http://www.moodle.org">Moodle</option>
<option value="http://www.drupal.org">Drupal</option>
</select>

Paste below Java before </body> tag (the hyperlink will open in same window)


<script type="text/javascript">
var urlmenu = document.getElementById('menu1');
urlmenu.onchange = function() {
document.location.href = this.value;
};
</script>

Paste below Java before </body> tag if you want it to open in new window.


<script type="text/javascript">
var urlmenu = document.getElementById( 'menu1' );
urlmenu.onchange = function() {
window.open(  this.options[ this.selectedIndex ].value );
};
</script>

Copyright © 2024 Siam Naulak.
magnifiercrossmenu