The Message Box


Type something in the box and then click "show me" to see the result.

If you cut and paste the code, make sure you place the portion between the two SCRIPT tags between the two Head tags. The code below consists of an HTML form which calls a script to produce a window with the script specified within the form. The form.txt1.value is the variable containing the text in the form, and the MsgBox function produces the message box. The javascript uses the alert Javascript function to produce the alert window.

<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

function MsgBox (textstring) {
alert (textstring) }

// - End of JavaScript - -->
</SCRIPT>

</HEAD>
 

<BODY>

<FORM>
<INPUT NAME="text1" TYPE=Text>
<INPUT NAME="submit" TYPE=Button VALUE="Show Me"
onClick="MsgBox(form.text1.value)">
</FORM>

</BODY>
</HTML>

 
More Popular JavaScript Uses
Talk to the authors! Credits
home