The world wide web(www) was designed to be an interactive technology. Html forms allow the users to enter parameters which will be posted to the server and the server responds to it accordingly. By this way a dynamic behaviour will be added to the website. To interact with the server we need the server side programming languages such as Asp, Java, Jsp, Php and other programming languages.
If we need to feed the parameters into a web page, insert a text field element. To do this, use <input>
element with the type attribute set to "text"
The text input given by the user can be read by a client side application coded in JavaScript or other client side application.
<form>..</form>
element is used to encapsulate the related text fields and other form elements.
<form>
elements cannot be nested one inside the other.
- To distinguish a The text field element has attributes other than the name and type.
disabled - It is use to disable the text field. The user cannot select the text field and the content of the field cannot be send to the server. maxlength - It is used to define the maximum number of characters that can be typed. The possible values are positive integers. readonly - It is used to prevent the user from changing the content of the text field. size - It is used to define the length of the text field in characters. if the size is less than maxlength, a horizontal scroll bar may appear. The possible values are positive integers. value - to set the initial value or default, value of the text field; the possible values are double quoted strings.The attributes of the <form>
element.
The <form>
element can be used by client-side or server-side applications to read data entered by the user and write the results from the web applications.
The browser encodes the forms data before sending it to the receiver. The technique used to encode depends on the value of the enctype attribute. The possible values of this attributes are
- "application/x-www-form-urlencoded" used in conjunction with the GET method(default settings) - the data is sent as a list of name=value pairs separated by and symbols. - Any white space is replaced by a +symbol. - Any non-alphanumeric character is replaced by % plus the ASCII code for that character. - Line brakes are replaced by %0D%0A% (CR/ LF) - "text/plain" used in conjunction with the mailto action for sending data by e-mail. This case is similar to the preceding case, but the white spaces are not by +symbols. -"multiform/form-data" used in conjunction with the POST method to send images or files to the server (i.e uploading)
To send the data to the receiver from the user filled data of the form fields, a submit button must be included in the <form>
element.
<input type="submit">
The following are the attributes of the submit button.
disabled - disables the submit button. name - it is the identifier for the element. value -represents the label that will appear on the button (default value is Submit Query)
The password element is similar to the text field and accepts the same attributes.
The value for the type attribute is "password" The value attribute of this element is required. When the user fills this field, the characters are not sown (* symbol appears in the field for each character typed) When the data is submitted, the real string of characters typed by the user will be sent to the server.
The hidden element is a special form element. It is special because it exists in the code of the page but it not rendered by the browser. It is used in the following way.
- To pass information between web application pages. - To add an identifier to the form the element belongs to .
To insert a hidden element into a form, use the <input> element with the type attribute set to a "hidden". Two other attributes are required name and value.
The checkbox is an <input>
element that can be selected or deselected by the user. Only the selected checkboxes are included in the submitted by the browser. The submitted checkboxes follow the standard syntax name1=value1 & name2=value2
name1 - the value of the name attribute of the checkbox <input>
element and
value1 - the value of the value attribute of the same checkbox <input>
element.
To insert a checkbox, use the <input>
element with the type attribute set to "checkbox". There is another attribute that can be used in conjunction with the checkbox element.
checked for when the default state of the checkbox element is selected
The radio button is very similar to the checkbox. It uses the same syntax and attributes.
- The value of the type attribute is "radio" - The user can select only one radio button in a group at a time(radio button are grouped according to the name attribute) - The browser renders them in the radio button style.
The <textarea>
element allows you to attach a multiline text field to a