Text Fields
-
Very common.
-
<INPUT TYPE="Text" NAME="FirstName" VALUE="Brandan" SIZE="25">
-
Where:
-
TYPE="Text" specifies that this is a text field.
-
NAME="FirstName" is the name of the field, which we can use in
JavaScript.
-
VALUE="Brandan" displays Brandan in the field by default. (Optional)
-
SIZE="25" the text field can have no more than 25 characters.
(Optional)
-
The JavaScript text object has properties:
-
name - the name assigned to the field in NAME.
-
defaultValue = the default value, the data in the VALUE
attribute.
-
value - the current value. Starts as the default,
but changes based on what the user entered. Be sure not to confuse
this with defaultValue!
-
In use:
-
To dynamically change the value,
document.form1.FirstName.value = "Spiff";
document.form1.FirstName.value = firstName;
-
To retrieve the value for further use in JavaScript,
firstName = document.form1.FirstName.value;
Text Areas
Home
Internet II: Day 4