Writing for the World Wide Web
Pulldown Forms Navigation
 Note:  This JavaScript requires an understanding of using HTML Forms.

Using a combination of HTML Forms and JavaScript, you can create a sort of pull-down menu. Basically, you create a small form whose sole purpose is to serve as a navigation tool. In fact, you would not want any other forms information in this particular form; you would want to create two separate forms if you had another form you wanted to display on the page. Here is the code for the navigation form:

<form name="menuform">
<select name="change" size="1" onchange="location.href=document.menuform.change.options[document.menuform.change.selectedIndex].value;">
<option selected="selected" value="">(choose a page)</option>
<option value="assignments.html">Assignments</option>
<option value="corporateanalysis.html">Corporate/Professional Website Analysis</option>
<option value="unprofessionalanalysis.html">"Unprofessional" Website Analysis</option>
<option value="analysiscompilation.html">Website Analysis Compilation</option>
<option value="print2online.html">Print to Online Conversion</option>
<option value="tutorial.html">Online Tutorial</option>
<option value="clientwebsite.html">Client Website</option>
</select>
</form>

Notice that the select tag, as well as the form itself, both have name attributes; this is so the JavaScript can reference the different value attributes from the option tags, thus changing the location of the page to the new URL. Here is a basic breakdown of what each part means:

  • form name="menuform"—naming the form allows the JavaScript to reference elements within the form
  • select name="change"—naming the select tag allows the JavaScript to reference elements within the list of options
  • onchange—this attribute executes the JavaScript function when the user selects a different item from the pull-down menu
  • document.menuform.change.options[].value—this refers to the form element that is selected; the JavaScript is looking in the HTML document for the form named "menuform" for the element of that form named "change" for a particular option and its value, the URL of the new page
  • [document.menuform.change.selectedIndex]—the information in the brackets ([]) is how the JavaScript refers to the selected option from the select list
  • option value="[page.html]"—the values you assign to the option tags will be the URLs that will load when you click on an item
The above lines of code will create the following display:


Home | Course Information | Assignments | Schedule | Class Notes | Resources | Student Pages