Here is an example of script that runs a basic pull-down menus. There are many ways in which menus can be designed, this example is one with a pull-down and a button, and it gives the user the time to consider and confirm the selected destination.
Select the name of your form to be used later in the JavaScript function. The opening tag <FORM NAME=”info”>achieves the task. Also choose a name for the menu, in this case jumpMenu Now, add the choices you’d like the user to see with the <OPTION>tag Close the pull-down menu area with the </select> And of course, add the button. In
The Pull-down menu is one of the simplest form of menus
This case it is lkabelled:GO!”, and on clicking it, the button invokes a JavaScript function jump() to perform a certain action.
The JavaScript function has really two components. The first is the
Varloc=document.info.jumpMenu.options(document.info.jumpMenu.selectedIndex). text:
Line which finds out what the user selected. The other part of jump() directs the user to the files corresponding to the choice of selection.
The entire scripts looks like this:
<HEAD> <SCRIPT LANGUAGE=”JavaScript”> function jump() { var loc=document.info.jumpMenu.options(document.info.jumpMenu.selectedIndex).text: if(loc== “Stanley Kubrick”) { location = “Stanley.html”, } else if (loc= = “Peter Greenaway”) { location = “Peter.html”, }else if (loc = = “Atom Egoyan”) { location = “Atom.html”,
A combination of pull-down menu and Go button gives the user time to consider his choice
} else if (loc = =- “Wim Wenders”) { location = “Wim.html”, } else if (loc = = “Mike Leigh”) { location = “Mike.html”; } else if (loc = = “Spike Lee”) { location = “Spike.html”; } } </SCRIPT>
<TITLE>main pull-down</TITLE> <HEAD> <FORM NAME=”info”> <select NAME= “jumpMenu”> <OPTION>Stanley Kubrick <OPTION>Peter Greenaway <OPTION>Atom Egoyan <OPTION>Wim Wenders <OPTION>Mike Leigh <OPTION>Spike Lee </select>s
<INPUT TYPE=BUTTON VALUE=”Go!” OnClick=”jump()”></FORM> |