HTML selection list without a submit button

HTML selection list without a submit button cover image
  1. Home
  2. HTML
  3. HTML selection list without a submit button

We all strive for good navigation on our web sites. It’s the aim of any web developer to have a page linked to another by a maximum of 2 clicks. Drop down lists (HTML <form> <select> elements) can be placed on all pages with links to the important pages on the web site. JavaScript allows us to make the visitor jump to a particular page by selecting an item from the drop down menu – and that too without a submit button. So you do not need to know any server-side language. JavaScript makes it easy to create a navigation list without a submit button. We employ the onChange() event handler along with location property of the window object.

// The following function is placed in the HTML head
function nav()
   var w = document.myform.mylist.selectedIndex;
   var url_add = document.myform.mylist.options[w].value;
   window.location.href = url_add;

// This code is placed in the HTML body
<form name="myform">
Jump to:
<select name="mylist" onChange="nav()">
<option value="">YouTube</option>
<option value="">9GAG</option>
<option value="">Wikipedia</option>
<option value="">Yahoo!</option>
<option value="">DeviantArt</option>
<option value="">Flickr</option>
<option value="">Twitter</option>
<option value="">Tumblr</option>

Click here to see how this works!

The values of all the options in this selection list are URLs. The onChange() event handler calls nav() function. This function stores the value of the selected item (the URL) in url_add variable. The window.location.href is then set to this variable.
Note: This selection list does not employ a “submit” button.

HTML JavaScript