Assignment 24: A Possible Answer


<script language="JavaScript">
var n = prompt("Hello! What`s your name?","Write it here")
var s = prompt("What state are you from?", "")

function placeit()
document.daform.receive.value=("Your name is " + n + ".")
document.daform.receive2.value=("Your are from " + s + ".")

<FORM NAME="daform">
<INPUT TYPE="text" NAME="receive">

<INPUT TYPE="text" NAME="receive2">

<INPUT TYPE="button" VALUE="Click to fill in prompt information" onClick="placeit(n)">



Gives you this:


     The prompts are normal prompts. The trick is putting two hierarchy statements in the function to act as placement items. Of course, you have to make two text boxes and be sure to give them both different names. Look at the code above: You'll note that the names keep all the elements quite separate.


Did You Get It?


Back to the Index Page