Colours and drop-down list boxes
This script will utilise properties of the document object to change the colour of the window as the user pleases. We will introduce drop-down list boxes as a useful way of letting the user select one of several pre-defined options.
<form name="myForm">
Set the background colour to
<select name="background">
<option value="blue">blue
<option value="black">black
<option value="yellow">yellow
<option value="white">white
</select><br>
Set the foreground colour to
<select name="foreground">
<option value="blue">blue
<option value="black">black
<option value="yellow">yellow
<option value="white">white
</select><br>
<input type="button" value="Make it so" onClick="{document.bgColor=myForm.background.value;document.fgColor=myForm.foreground.value;}">
</form>
The code is implemented below: