Here is a sample FORM element:
<TABLE><FORM action="http://127.0.0.1:21000/books/CGI/MyCGI"> <TR><TD>First Name <TD><INPUT type="text" name="first" value="Joe"> <TR><TD>Last Name <TD><INPUT type="text" name="last" value="Blow"> <TR> <TD><BUTTON type="submit" name="push" value="xx"> ENTER</BUTTON> </FORM></TABLE> |
The elements included in the FORM contents, such as <INPUT> and <BUTTON> in the example are called controls. They all have a name which is the value assigned to their name attribute and a value which can be diversely defined. For an INPUT control, it is the value assigned to its value attribute ('John' and 'Blow' in the example); for a BUTTON control, it is the contents of the element ('ENTER' in the example).
As you click the 'ENTER' control, data from the FORM will be sent over to the destination specified by the action attribute of the FORM element. As set out here, the destination is the '21000' port of your own computer. Normally there should be a Web Server to monitor this port.
To get some insight into the working of the communications, you can run the JAVA program whose full name is web.MyServer
, which is in the classes.web directory, then click the 'ENTER' button in the form on the left.
This program monitors the 21000 port of your computer, and when data is received, reads it and writes it out to the form.txt file in the directory from which the java command is entered, and also to the user screen for immediate examination.
Apart from the first line, an application normally never sees the data our JAVA program sees. They are HTTP protocol data, specifically request header data. As the file specified in the action attribute does not exist here, you will be taken to another page with a full page error message saying so. The experiment was devised to show you the data transmitted. Only with some more programming effort, can you make the JAVA program a Web Server.
The information useful to an application program is in the first line:
GET book/CGI/MyCGI?first=Joe&last=Blow&push=ENTER HTTP/1.1 |
- | the retrieving method to use by the server is 'GET' |
- | the application program file identification, complete with its directory path, is 'book/CGI/MyCGI '
|
- | the element named 'first' has the value 'Joe' |
- | the element named 'last' has the value 'Blow' |
- | the element named 'push' has the value 'ENTER' |
- | the HTTP version is 1.1 |
1. SAMPLES
1.1 Text Field, Radio and Checkbox
Here is a sample page with text fields for data entry, radio buttons for exclusive choices and check boxes for multiple choices.<FORM action="http://www.hatayservice.com:8080/books/servlet/MyServlet" method="GET"> <TABLE> <TR><TD>First Name<TD colspan=2"> <INPUT type="text" name="first"> <TR><TD>Last Name<TD colspan="2"> <INPUT type="text" name="last"> <TR valign="top"><TD>Sex<TD> <INPUT type="radio" name="sex" value="male">male<br> <INPUT type="radio" name="sex" value="female">female <TR valign="top"><TD colspan="2">Hobbies -- click one or more<TD> <INPUT type="checkbox" name="sport">sport<br> <INPUT type="checkbox" name="culture">culture<br> <INPUT type="checkbox" name="bird">bird watching<br> <INPUT type="checkbox" name="travels">travels<br> <TR><TD> <BUTTON type="submit" name="push" value="xx"> ENTER</BUTTON> </FORM></TABLE>Please click here to display the page.
The controls are wrapped in a table for presentation. Elements pertaining to the definition of the form are made to stand out in blue.
1.1.1 The FORM element The control definitions are included in the contents of a FORM element. This has 2 attributes:
| ||||||||||
1.1.2 Text fields The text field controls are defined by the INPUT elements with the type="text" attribute.The name attributes define the names of the controls. These are 'first' and 'last' in the example. | ||||||||||
1.1.3 The radio controls The radio controls are defined by the INPUT elements with the type="radio" attribute. Both of these elements have the same name (name="sex"); this puts them into the same group where only one element can be checked at any given time | ||||||||||
1.1.4 The checkbox controls The checkbox controls are defined by the INPUT elements with the type="checkbox" attribute. Any number of checkboxes can be checked a given time. | ||||||||||
1.1.5 The submit button The submit button is defined by the BUTTON elements with the type="submit" attribute. When you click on the submit button, the information assigned to the controls are sent over to the Web Server as a character string appended to the application URL:
| ||||||||||
1.1.6 Data presentation The data string sent to the Web Server is separated from the application identifcation by a question mark. Data items in the string are separated by ampersand signs (&). Any special characters in the data are replaced by their hexadecimal codes, preceded by the percent (%) sign. You can run the web.MyServer Java program as shown in the above introduction, to capture and see the message transmitted to the Web Server. This is for informational purpose. In practical work with a Web Server (such as the widely popular Tomcat Web Server), applications are presented the data in decoded form. |
1.2 Menu Selection
<HTML><HEAD><TITLE>A SELECT</TITLE></HEAD><BODY> <FORM action="http://localhost:21000/books/servlet/MyServlet" method="POST"> <TABLE><TR valign="top"><TD>Menu<TD> <SELECT name="Poetry"> <OPTGROUP label="shakespeare">William Shakespeare <OPTION label="macbeth" onclick="location='../Samples/PoemMacbeth.html'";> Macbeth</OPTION> <OPTION label="hamlet" selected onclick="location='../Samples/PoemHamlet.html'";> Hamlet</OPTION> </OPTGROUP> <OPTION label="wordsworth" onclick="location='../Samples/PoemWordsworth.html'";> William Wordsworth</OPTION> <OPTION label="shelley" onclick="location='../Samples/PoemShelley.html'";> Percy B. Shelley</OPTION> <OPTION value="byron" onclick="location='../Samples/PoemByron.html'";> George G. Lord Byron</OPTION> <OPTION value="tennyson" onclick="location='../Samples/PoemTennyson.html'";> Alfred Lord Tennyson</OPTION> </SELECT> <TR><TD> <BUTTON type="submit" name="push" value="xx">SEND</BUTTON><TD> </TABLE> </FORM> </BODY></HTML>To see the page, please click here.
1.2.1 The SELECT and OPTION elements
The SELECT element creates a menu control. Options of the menu are defined by the OPTION elements. The option labels (i.e. what you see in the menu) are the contents of the elements. They are in a menu list. As no size attribute is present in the SELECT element here, only one line of the list is visible. With the Microsoft Internet Explorer and the Netscape Navigator browsers, an arrowed button can be used to open the list and see all of the option labels. You can select one of the option:Then the list will close and the selected option shows on the one ordinarily visible line.
1.2.2 The onclick event handling attribute
Well, in our example, if you click an option, normally the onclick attribute present in the OPTION tag is activated first. Their assigned script are in red in the above; they will take you to the specified HTML page. When returning from this page, you will see the selected option on the Menu visible line. This will happen with Netscape Navigator 7.1, not with Internet Explorer 6 which does not abide by the standard here on this point.1.2.3 The OPTGROUP element
The OPTGROUP element contents is a group of OPTIONs. According to the HTML standard, only the group label ("shakespeare") would show on the menu, at first; by clicking it you would display the options in the group. Presently, with both Internet Explorer and Netscape Navigator, the group label does show, but so do the component option labels also.1.2.4 Preselected item
The selected attribute in the OPTION tag named "hamlet" pre-selects the associated label, i.e. this the label is selected when the page is loaded, and will remain so if you don't select another one.1.2.5 Submitted data
When you click the SUBMIT button (labelled "SEND" in the example), the information from the SELECT element will be:select_name=selected_label |
According the W3C reference document, the label of an option is defined as follows:
- | a long label is defined by the contents of the OPTION element; this what shows in the displayed menu |
- | a short label is defined by the label attribute; the short label is the value of the SELECT element, in the pair name/value as sent to the application, when the option is selected and the submit button is clicked; this label, when so defined, is to replace the long one, both in the menu list and in the name/value pair sent to the application |
1.2.6 The POST method
Finally, the method specified in the FORM tag is POST. You can check, using the web.MyServer programm that the data is in the message-body, instead of the request line.1.3 Enhanced presentation and access
<HTML><HEAD><TITLE>PRESENTATION FORM</TITLE></HEAD><BODY> <b><font color="red">SUBSCRIBER</font></b> <FORM action="http://localhost:21000/books/servlet/MyServlet"> <FIELDSET><LEGEND><b><font color="blue">IDENTITY</font></b></LEGEND> <TABLE> <TR><TD><LABEL>First Name</LABEL><TD> <INPUT type="text" name="first" accesskey="F" tabindex="2"><br> <TR><TD><LABEL>Last Name</LABEL><TD> <INPUT type="text" name="last" accesskey="L" tabindex="1"> </TABLE> </FIELDSET> <FIELDSET><LEGEND><b>PROFILE</b></LEGEND> <TABLE> <TR valign="top"><TD>Sex<TD> <INPUT type="radio" name="sex" value="male" tabindex="4">male<br> <INPUT type="radio" name="sex" value="female" tabindex="3">female<TD> <TR valign="top"><TD class="white" colspan="2">Hobbies -- click one or more<TD> <INPUT type="checkbox" name="sport">sport<br> <INPUT type="checkbox" name="culture">culture<br> <INPUT type="checkbox" name="bird">bird watching<br> <INPUT type="checkbox" name="travels" tabindex="5">travels<br> <TR><TD> <BUTTON type="submit" name="push" value="xxxx"> ENTER</BUTTON> </TABLE> </FIELDSET> </FORM></BODY></HTML>Please click here to see the displayed page.
1.3.1 The FIELDSET and LEGEND elements
Elements can be enclosed in a FIELDSET elements to form a group. The corresponding controls are then set in a frame. The LEGEND elements can be used to define a caption displayed on top of the frame.1.3.2 The LABEL element
You can use the LABEL element to place labels before or after a control, as is done here for the INPUT text fields. But they are quite unnecessary, as you can put a bare text wherever you choose on the HTML page.1.3.3 Access key and tabbing index
The accesskey and tabindex attributes help organize the user's navigation across the HTML page:- | The accesskey="F" and accesskey="L" attributes in the above assign the letters "F" and "L" respectively to the controls names "first" and "last". This makes it possible for you to focus on these controls using the "F" and "L" keys on the keyboard. With an Windows system, you have to hold down the ALT key when pressing the letter "F" or "L". Please try it. |
- | The tabindex attributes define the tabbing order among the controls: when you press the TAB key, the cursor will move among the control in the increasing order of the assigned tabindex values; the controls without the tabindex attribute come last, and among themselves, they are in the "natural" order of the page: left to right, top to bottom. You can try it; this works fine with Netscape 7.1, but a control can be skipped with Internet Explorer 6.0. |
2. USAGE
The FORM element creates a data entry form that helps the user enter data and transmit them to a remote application.2.1 The controls
The contents of the FORM element hold form-elements that are used to define the data and to transmit them. These elements are called controls. The different types of control are:- | Text fields: | one line data fields that can receive character input from the keyboard They are created by the INPUT element with the type="text" attribute |
- | Text area fields: | multi line data fields that can receive character input from the keyboard They are created by the TEXTAREA element |
- | Checkbox controls: | switches that alternately takes on the ON and OFF state as they are repeatredly clicked on by the user They are created by the INPUT element with the type="checkbox" attribute |
- | Radio controls: | switches formed into groups where only one of the controls can have the ON state They are created by an INPUT element with the type="radio" attribute |
- | Password fields: | Text fields where the user can enter a password which is not displayed in a legible form (usually as a sequence of asterisks) They are created by an INPUT element with the type="password" attribute |
- | Menu options: | Labels set in a menu, to be selected by the user They are created by OPTION elements included in the contents of a SELECT element. OPTION elements in a SELECT contents can form groups enclosed in OPTGROUP elements. |
- | Hidden fields: | Text fields not rendered on the HTML page They are created by an INPUT element with the type="hidden" attribute |
- | Image controls: | submit button displaying an image on its face; when clicked it causes the pixel coordinates of the clicked point to be transmitted to the server, along with the information from the other controls in the FORM They are created by an INPUT element with the type="image" attribute and the image identified by the src="uri" attibute, or alternatively by a BUTTON element with a type="submit" attribute, and an IMG element in the contents. |
- | File controls: | file select controls that allow the user to browse the directory tree of the host computer, to select a file path name; this name is retrieved into the text field of the control They are created by an INPUT element with the type="file" attribute |
- | Submit buttons: | Buttons used to cause the form data to be transmitted to the remote Web Server They are created by a BUTTON element with the type="submit" attribute, or alternatively by an INPUT element with the type="submit" attribute |
- | Reset buttons: | Buttons used reset all the controls of a FORM to their initial values They are created by a BUTTON element with the type="reset" attribute, or alternatively by an INPUT element with the type="reset" attribute |
- | Push buttons: | Buttons used to allow interaction of the user They are created by a BUTTON element with the type="button" attribute. |
2.2 Transmitted data
Data from the FORM are transmitted to the remotename=value |
%20 - space
%22 - double quote (")
%2F - slash (/)
%3A - colon (:)
etc...
data-item&data-item& ...&data-item |
firstName=John&surname=Blow&age=26&SUBMIT=push |
2.3 Focus
When you click on a control, you make it active. For example, clicking in a text field you make it ready to receive the characters you type on the keyboard; clicking on an option in a menu you make it highlighted to show that it is selected. The control is said to have focus.2.4 Tabbing navigation
When the user types data on the keyboard, the typed character goes into the control (a text field or a textarea field) that has focus. Focus is gained by a control when the user clicks on it. Alternatively, the user can move focus from one control to another by pressing the TAB key. This is tabbing navigationThis order can be changed by using the tabindex attribute. When the TAB key is pressed, the controls with a tabindex attribute will get focus in the order of the tabindex values. Ths controls where the tabindex is not present will come next, in the natural tabbing order among them.
2.5 Events
Events caused by user action with the key board (key events) or with the mouse (mouse events) can be reacted to using scripts assigned to event handling attributes of the control-defining elements.User action with the keyboard or the mouse are handled by attribute handling events that can be used on almost all elements, even outide a form. These attributes are described as common attributes -- please click here to show them.
Attributes specifically used with form controls are:
ATTRIBUTE | When activated |
onfocus | The control gets focus |
onblur | The control loses focus |
onselect | Used with a text or text area field - data in the control is selected by the user |
onchange | Used with a text or text area filed - data in the control is changed by the user |
onsubmit | Used in a FORM element - the SUBMIT key is clicked |
onreset | Used in a FORM element - the RESET key is clicked |
3. SYNTAX
3.0 The FORM element
<FORM action=uri method="{GET|POST}" other-attributes > normal BODY contents <LABEL>text</LABEL> <INPUT type="xxx" other-atributes > <LABEL>text</LABEL> <TEXTAREA>text-contents</TEXTAREA> <BUTTON type="xxx" name="name" > [<IMG server-side-image>] </BUTTON> <SELECT name="menu-name" size="n" "other-attributes"> <OPTION label="short-label" "other-attributes">longer-label<</OPTION> <OPTGROUP label="text" [disabled]> <OPTION ... > </OPTGROUP> </SELECT> <FIELDSET> character-data <LEGEND>inline-text</LEGEND> normal-flow </FIELDSET> </FORM>
3.0.1 FORM attributes
Specific attributes of the FORM element are:- |
action="uri" specifies the URI of a processing program. An example is:
| ||
- |
method="{get|post}" specifies the HTTP method to be used to submit the form data An example is:
| ||
- |
name="string" defines the form name. An example is:
| ||
- |
onsubmit="script" specifies a script to be run when the form is submitted. An example is:
| ||
- |
onreset="script" specifies a script to be run when the form is reset. An example is:
| ||
- |
enctype="type" specifies the MIME content type of the submitted data An example is:
| ||
- |
accept="types" specifies a list of content-types that the processing program can accept An example is:
| ||
- |
accept-charset="list" specifies a list of character sets that the processing program can accept. An example is:
|
3.0.2 FORM contents
A <FORM> element can contain text interspersed with the following elements:INPUT | which defines one of these controls: | ||||||||||||||||||||
| |||||||||||||||||||||
TEXTAREA | which defines a multi-line text input control | ||||||||||||||||||||
BUTTON | which can define one of the following controls: | ||||||||||||||||||||
| |||||||||||||||||||||
SELECT | which defines a menu with items to select from | ||||||||||||||||||||
| |||||||||||||||||||||
Other elements that can be set in the contents of the SELECT elements are: | |||||||||||||||||||||
|
3.1 The INPUT element
The type attribute of the INPUT element determines the type of control created by the element.3.1.0 INPUT types
TEXT type (type="text") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Data input: <INPUT type="text" name="sample" value="initial"></FORM>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The TEXT type INPUT creates a single line text input control. When submitted, the control current value is sent to the processing program, as a pair control-name=value. This value is:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PASSWORD type (type="password") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Password: <INPUT type="password" name="sample" value="initial"></FORM>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The text the user types in is not readable; but it becomes the value of the control and is sent when the form is submitted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CHECKBOX type (type="checkbox") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Check here: <INPUT type="checkbox" name="sample" value="initial">
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A CHECKBOX is a toggle that switches on and off as the user clicks on it; usually, the "ON" or "checked" state is indicated by a check or a cross mark, the "OFF" or "unchecked" state by the control being blank. The "name" and "value" attributes must be used to specify the control-name and the value of the CHECKBOX. Multiple CHECKBOX can share the same name; values should be different. When the form is submitted, the control-name=value pairs of all checked CHECKBOX elements are sent to the processing program. If no value is specified, then the names must be different and all checked controls have their information sent as a control-name=on pair, where 'on' appears as is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RADIO type (type="radio") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Choose one:<br>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A RADIO button is a round shaped toggle that switched on and off as the user clicks on it; all of the RADIO elements having the same name (defined by the "name" attribute) make up a group in which only one button can have the "ON" state. Normally, in the inital state, one of the button is defined as being "ON" ("check" attribute present); otherwise, the resulting state is up to the user agent (the browser). The "name" and "value" attributes must be used to specify the control-name and the value of the RADIO button. When the form is submitted, the control-name=value pair of the checked RADIO button is sent to the processing program. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SUBMIT type (type="submit") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Click here to submit: <INPUT type="submit" name="sample" value="initial"></FORM>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
One or more SUBMIT buttons can be created in a FORM element. The label shown on the button is defined by the "name" attribute. A click on a submit button causes the form to be submitted to the processing program specified in the "action" attribute. A SUBMIT button can also be created by a BUTTON element. The W3C recommendation on HTML 4 suggests that buttons created by an INPUT element be "flat" whereas those by a BUTTON element be rendered with relief, and show an up/down motion when clicked. The control-name=value pair of the clicked SUBMIT button is sent along with the other submitted data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RESET type (type="reset") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM>Click here to reset: <INPUT type="reset" name="sample" value="initial"></FORM>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
One or more RESET buttons can be created in a FORM. The label shown on the control is defined by the "name" attribute. A click on a RESET button causes all the controls to return to their initial values A RESET button can also be created by a BUTTON element. The W3C recommendation on HTML 4 suggests that buttons created by an INPUT element be "flat" whereas those by a BUTTON element be rendered with relief, and show an up/down motion when clicked. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IMAGE type (type="image") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<FORM><INPUT type="image" name="sample" value="initial" src="../Images/manitoba-rose.art" width="100" class="white">
The image is scaled using the width attribute (height is adjusted accordingly)</FORM> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
An INPUT element with the "IMAGE" type creates a submit button decorated with an image. The image is identified by the src atribute. The button reacts as a submit button and a sensitive server side image, but no "ismap" attribute is needed; when the user clicks on the image:
3.1.1 INPUT attributes Some of the usual attributes of the INPUT element are:
3.1.2 INPUT contents The INPUT element has NO contents (ending tag not permitted)3.2 The TEXTAREA element <FORM> <TEXTAREA rows="3" cols="60" name="TEXT">Initial value</TEXTAREA> </FORM> The area is allocated 3 rows of 60 characters each:
3.2.1 TEXTAREA attributes Specific attributes of the TEXTAREA element are:
3.2.2 TEXTAREA contents The contents of the element is its initial value.3.3 The BUTTON element The 3 types of button are:- submit - reset - button (push button) SUBMIT type <FORM action="http://localhost:21000/"> <BUTTON type="submit" name="submit_Name_1" value="submit_value_1">MySUBMIT</BUTTON> <BUTTON type="submit" name="submit_Name_2" value="submit_value_2">MySUBMIT-2</BUTTON> </FORM> RESET type <FORM><Data input: <INPUT type="text" name="MyText" value="initial"><br> BUTTON type="reset" name="reset_Name" value="reset_value">MyRESET</BUTTON> </FORM> BUTTON type <FORM><BUTTON type="button" name="push_Button" value="pushed_value" onclick="display.value='Button clicked';">MyPUSH</BUTTON> <INPUT type="text" name="display">
3.3.1 BUTTON attributes Some of the attributes usually associated with the BUTTON elements are:
3.3.2 BUTTON contents The W3C HTML 4.01 specifications do not define the role of the BUTTON element contents in an obvious way.With Internet Explorer 6.0, these, not the value attribute value make up the value of the button, which is displayed on the button face, and transmitted on submission, in the control-name=value pair as the information from the button. With Nestcape Navigator 7.1, the contents of the BUTTON element constitute the label displayed on the button face, whereas the value of the value attribute is transmitted in the control-name=value pair as the information from the button. 3.3.3 Image buttons Submit buttons can be made to show an image on their face. This is achieved by including an IMG element in the contents of the BUTTON element.When the button is clicked, the form is submitted. As per the HTML 4.01 standard, the pixel coordinates of the point where the button is clicked are sent to the application along with the data from the other controls. But this is not always done so. The ILLFormImageButton shows an example of image buttons defined with both the INPUT and the BUTTON elements. 3.4 The SELECT element <SELECT name="menu_name" size="n" "other-attributes"> <OPTION label="short-label" value="short-label" "other-attributes">longer-label<</OPTION> <OPTGROUP label="text" [disabled]> <OPTION ... > </OPTGROUP> </SELECT>The SELECT element defines a menu that contains a number of items. An item is defined by an OPTION element included in the contents of the SELECT element. Menu items can be grouped by enclosing their defining OPTION elements in the contents of an OPTGROUP element included in the SELECT contents. 3.4.1 SELECT attributes Some commonly used attributes of the SELECT element are:
When multiple attribute is specified the menu can be displayed differently depending on the browser. When no size attribute is specified, a number of lines are made permanently visible. When a size attribute is specified, Internet Explorer renders it well. The behaviour of Netscape Navigator 7.1 is still somewhat erratic.
3.4.2 SELECT contents A SELECT element contains at least one OPTION element. The OPTION elements can be enclosed within OPTGROUP elements to form a group.<SELECT attributes <OPTION attributes> contents </OPTION> ... <OPTGROUP attributes> <OPTION attributes> .... </OPTGROUP> </SELECT> 3.5 The OPTION element 3.5.1 OPTION attributes Some commonly used attributes of the OPTION element are:
- the value of the label attribute defines the option short name With both the Netscape Navigator and the Internet Explorer browsers, the element contents define the option long name, and the value attribute value, the short name. Other permissible attributes are:
3.5.2 OPTION contents The contents of the OPTION element make up the option long name.3.6 The OPTGROUP element 3.6.1 OPTGROUP attributes Some commonly used attributes of the OPTGROUP element are:
3.6.2 OPTGROUP contents An OPTGROUP element contains a number of OPTION elements:<OPTGROUP attributes> <OPTION attributes> ... </OPTION> <OPTION attributes> ... </OPTION> ... </OPTGROUP> 3.7 The FIELDSET element The FIELDSET element encloses a number of HTML elements in its contents. On the presented HTML page, it is rendered as a bordered frame enclosing the controls defined by these elements3.7.1 FIELDSET attributes No attribute3.7.2 FIELDSET contents The FIELDSET element contains, in any order:- an optional LEGEND element - ordinary HTML text - a number of HTML elements. 3.8 The LEGEND element The LEGEND element defines a caption that is displayed on top of the FIELDSET frame.3.8.1 LEGEND attributes Some commonly used attributes of the OPTION element are:
3.8.2 LEGEND contents The contents constitute the caption displayed on the FRAMESET frame.3.9 The LABEL element 3.9.1 LABEL attributes Defines a label for a form-control.Some commonly used attributes of the LABEL element are:
3.9.2 LABEL contents 3.10 General use attributes Presented here are the attributes of general use:- attributes applicable to more than one control - attribute with a general scope extending farther than the Form controls 3.10.1 Form control attributes These attributes are permissible in more than one control type:
3.10.2 General use attributes 4. REFERENCES HTML 4.01 Specifications - W3C Recommendations 24 december, 1999 - Latest version: http://www.w3.org/TR/html401contents introduction reference index previous next |