WDN Logo

home-icon Home / HTML / HTML selection list without a submit button

HTML selection list without a submit button

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="http://www.youtube.com">YouTube</option>
<option value="http://www.9gag.com">9GAG</option>
<option value="http://www.wikipedia.org">Wikipedia</option>
<option value="http://www.yahoo.com">Yahoo!</option>
<option value="http://www.deviantart.com">DeviantArt</option>
<option value="http://www.flickr.com">Flickr</option>
<option value="http://www.twitter.com">Twitter</option>
<option value="http://www.tumblr.com">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.

Sponsored Links


Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

How a Computer Engineering student feels, When the PROGRAM Compiles

Sponsored Links


How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]


A feature on the Kindle 5 measures reading speed and can inform you when the chapter or the book will be finished. [more...]

Share on Whats app Share on Facebook Share on Twitter Share on Google plus