JavaScript: Drop-Menu Example 2
Document Header Code
This portion goes in the <head> of the page, without changes:
|
<script language="JavaScript" type="text/javascript"><!-- // original code by Bill Trefzger 12/12/96, // modified by Melvin Waller Jr 7/1/02 function go(jsm) { var menujs = eval('document.jsmenu' + jsm + '.jsm' + jsm); if (menujs.options[menujs.selectedIndex].value != "") { location = menujs.options[menujs.selectedIndex].value }} // --></script> |
Document Body Code
This portion goes in the BODY of the page, changes defined below:
|
<h3><a href="SubjectURL">SubjectTITLE</a></h3> <script type="text/javascript"><!-- document.write('<form name="jsmenu2" action="javascript:void(null)" method="post">'); document.write('<select name="jsm2">'); document.write('<option value="">SubjectTITLE (choose one)</option>'); document.write('<option value="">--------------------</option>'); document.write('<option value="LinkURL">LinkTITLE</option>'); document.write('<option value="LinkURL">LinkTITLE</option>'); document.write('<option value="LinkURL">LinkTITLE</option>'); document.write('</select><input type="button" value="Go" onclick="go(2)"></form>'); // --></script> |
The second portion should then have the following changes made:
First, remember that the 'Subject' of this drop list must have a standard HTML link in this page which goes to another page that lists all of the links presented in this drop list. This link should appear in the page immediately prior to this drop list for proper accessibility.
- SubjectURL = the web address of the page that introduces this subject (this page must contain the same links as are presented in the list).
- SubjectTITLE = the title of the subject contained in this list.
- LinkURL = (one per link) the web address of the file to be linked.
- LinkTITLE = (one per link) the title of the document to be linked.
The 'Link' lines may be repeated as many times as needed.
If multiple lists are to be used in one document then each list must have a unique number. The list's number is specified in 3 places in the script. They are:
name="jsmenu#", name="jsm#", and onclick="go(#)"
(where # would be replaced with the list's number).
If the apostrophe character (') must be used in the TITLE or URL of any of these links, then it must be preceded with a back-slash (\') for the JavaScript to work properly without errors.
