Main Menu
Multiwingspan Home Page
Multiwingspan Games
Gnasher @ Multiwingspan
Multiwingspan Calendar
Multiwingspan Clock
About Multiwingspan
Programming
Visual Basic 6.0 Guide
Visual Basic 6.0 Examples
Turbo Pascal Guide
SWI Prolog Guide
Visual Basic 2005 Guide
Structured Query Language
Web Design
HTML Design Tasks
Introduction To HTML
Introduction To CSS
Introduction To Javascript
Notes
AS/A2 Level Computing

Javascript Guide
List Boxes

HTML

<form name="myForm">
<select name="myDrop">
<option SELECTED value="http://www.google.co.uk/">Google</option>
<option value= "http://lycos.co.uk/">Lycos</option>
</select>
<input type="button" onclick="loader()" value="Click">
</form>

The value settings for each of the option tags will be used by the function which loads the page. The word SELECTED in the first option ensures that the specified option is selected on loading the page.

Javascript in <head>

<script language="Javascript">
function loader() {
var whichone = document.myForm.myDrop.selectedIndex
var whoami = document.myForm.myDrop.options[whichone].value
self.location =whoami
}
</script>

In line 3 the script checks which of the options has been selected. Line 4 looks for the value of the selected option. Line 5 changes the location value (web address) of the current page to this value, effectively linking to the chosen web page.

Exercise 13

Think how much nicer the quiz you made would be if it were multiple choice. Change the format of the quiz so that users can select from at least 3 possible answers.

Return To Javascript Guide || Return To Homepage