| Ken
Ward's JavaScript Tutorial 1 |
The following form has a text box. When you write your name
in the text box, you get - well - see for yourself. Enter your name and click the
button.
If you entered your name in the box, then I hope you saw it in the alert. Here's the
code in the HEAD of the document:
<script type= "text/javascript">
<!-- //
function alert3()
{
Namer=document.Form1.YourName.value;
alert( 'Your name is '+Namer);
}
//-->
</script>
Namer is variable that holds your name which you
entered in the text box. The alert adds some text, 'Your name is ' in front of the name so
you get the result in the alert that pops up. Note any text we want to write is put in
single (') or double quotes (") (but not both!). Next we look at calling a function
from text.
Next: Changing background colour
|
Contents
|