next up previous contents
Next: The SELECT Command Up: Laying Out Forms Previous: Laying Out Forms

The INPUT command

Now you have an empty form, you probably want to provide some boxes and buttons that the user can set. These are created using the INPUT tag. This is used in a similar way to the IMG tag for images - there's no need for a terminating tag as it doesn't surround anything. There are several types of INPUT tag, denoted by the TYPE attribute:

<INPUT TYPE=text NAME=users_name>

This is a simple text entry field that we've called `` users_name''. The user never sees this NAME attribute displayed on her client - it is purely so we can keep track of which field is which when we come to process the form. Text entries also allow you to specify:
VALUE="enter your name here"

This lets you specify the default text to appear in the entry box.
SIZE=60,3

This lets you specify the size of the entry box is characters. For example the above says the entry box should be 60 characters wide and three lines high.
MAXLENGTH=8

This lets you specify the maximum number of characters you'll allow to be entered in a single line text entry box. For instance, you might only allow a user to enter eight characters as their user name.

<INPUT TYPE=password NAME=users_passwd>

This is also a text entry field, but the characters the user types are displayed as stars so that other people can't read the password from their screen. Password fields also support the VALUE, SIZE and MAXLENGTH attributes.

<INPUT TYPE=checkbox NAME=veggie>

This is a single button which is either on or off. Checkboxes also support the following attributes:
VALUE="true"

This is the value to return if the checkbox is set to ``on''. If it's set to ``off'', no value is returned.
CHECKED

This says that the checkbox is ``on'' by default.

<INPUT TYPE=radio NAME=food_style VALUE=indian>
<INPUT TYPE=radio NAME=food_style VALUE=chinese>

These are a collection of buttons. Radio buttons with the same name are grouped together so that selecting one of them turns the others off like the channel tuning buttons on some radios. Radio buttons also support the VALUE and CHECKED attributes, but only one radio button can be specified as CHECKED.

<INPUT TYPE=submit VALUE="Press Me to Submit">

This is a button that submits the contents of the form to the server using the method in the surrounding FORM. Submit buttons don't have a NAME attribute, but you can specify the label for the button using a VALUE attribute.

<INPUT TYPE=reset VALUE="Press Me to Start Again">

This is a button that causes the various boxes and buttons in the form to reset to their default values. Reset buttons also don't have a NAME attribute, and allow a VALUE attribute to label the button.



next up previous contents
Next: The SELECT Command Up: Laying Out Forms Previous: Laying Out Forms



Jon Crowcroft
Wed May 10 11:46:29 BST 1995