Take the test, then study the source code below.
The most complicated part of the code is the section that creates the
twelve option buttons - the easy way to make the buttons is with Insert>Form>Option
button but don't forget to modify the code that FrontPage generates
to make it match the code below. The code includes a section in VBScript which should work fine in
Internet Explorer but may not work in older versions of Netscape
Navigator (code written in JavaScript is compatible with both browsers
but is more difficult to write.) Pay attention to how the radio buttons' properties were set,
including their IDs. Note that this form does not send data to a separate page
as forms usually do - instead pressing the 'Click when done' button
triggers the VBScript which changes the properties of the various
controls. To simplify the code, labels are not defined for the option
buttons in these questions (labels allow you to select an answer by
clicking on its corresponding label as well as by clicking the option
button itself.
<FORM NAME="Form1">
<ol><li>Which planet is closest to the sun?<br>
<input type="radio" name="Closest_Planet" value="Earth" id="fp5">
Earth
<input type="radio" name="Closest_Planet" value="Venus" id="fp6">
Venus
<input type="radio" name="Closest_Planet" value="Saturn" id="fp7">
Saturn
<input type="radio" name="Closest_Planet" value="Mercury" id="Mercury">
Mercury<br><br></li>
<li>Who was the greatest scientist of all time?<br>
<input type="radio" name="Greatest_Scientist" value="Newton" id="Newton">
Newton
<input type="radio" name="Greatest_Scientist" value="Einstein" id="fp2">
Einstein
<input type="radio" name="Greatest_Scientist" value="Maxwell" id="fp3">
Maxwell
<input type="radio" name="Greatest_Scientist" value="Galileo" id="fp4">
Galileo<br><br></li>
<li>What is the capital of Australia?<br>
<input type="radio" name="Australia_Capital" value="Melbourne" id="fp9">
Melbourne
<input type="radio" name="Australia_Capital" value="Sydney" id="fp10">
Sydney
<input type="radio" name="Australia_Capital" value="Canberra" id="Canberra">
Canberra
<input type="radio" name="Australia_Capital" value="Adelaide" id="fp12">
Adelaide</li></ol><p>
<INPUT TYPE="Button" NAME="Button1" VALUE="Click when done">
Pressing this button will display the correct answers as well as your score.
</p><p>
<input type="reset" value="Reset" name="Reset">
</p><p>
Your score: <input type="text" name="Score" size="7">
</p></FORM>
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
score = 0
if Form1.Newton.checked = true then score = score +1 else Form1.Newton.checked = true
if Form1.Mercury.checked = true then score = score +1 else Form1.Mercury.checked = true
if Form1.Canberra.checked = true then score = score +1 else Form1.Canberra.checked = true
Form1.Score.value = score
</SCRIPT>