JavaScript: Drop-Menu Example 1
Document Header Code
This portion goes in the HEAD of the page, without changes:
|
<script 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:
|
<script language="JavaScript" type="text/javascript"><!-- document.write('<form name="jsmenu1" action="javascript:void(null)" method="post">'); document.write('<select name="jsm1">'); document.write('<option value="SubjectURL">SubjectTITLE</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(1)"></form>'); // --></script><noscript> <h3><a href="SubjectURL">SubjectTITLE</a></h3> </noscript> |
The second portion should have the following changes made:
- SubjectURL = (two places) the web address of the page that introduces this subject (this page must contain the same links as are presented in this list).
- SubjectTITLE = (two places) the title of the page introducing this subject.
- 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.
.[Updated: Sunday, November 18, 2007]
