JavaScript

Monday April 7, 2025
updated: April 10, 2002

 
Home
Getting Started
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Resources
Credits

 

 


Assignment 3

In lesson 4 you learned how use the prompt box to get input from a user. We can get information from a user by using a form. To do this you have to declare the variables:

var a = document.form1.vara.value
var b = document.form1.varb.value

You also need the code:

<FORM ACTION="" METHOD=POST name=form1>
<P>Input the Variable A: <INPUT TYPE=text NAME=vara VALUE="" </P>
<P>Input the Variable B: <INPUT TYPE=text NAME=varb VALUE="" </P> </FORM>

Using this information write an HTML page with accompanying JavaScript where the user input's their name via a form and then the corresponding verse of "The Name Game" is written to the screen. For example, if the user entered "Nick", the page would print

Nick, Nick bo Bick
Banana Fanna Fo Fick
Mee Mi Mo Mick
Nick

If you don't remember the rules to the name game, it is OK if you make up your own rules.


© 2002 Tracy Johnson