Introduction to Form objects in HTML - Technology & Web designing

Breaking

Sunday, 3 May 2020

Introduction to Form objects in HTML

Form and Form objects :

Forms are used to accept or input the data from user. The form consist of form object/elements. Form elements or objects are textbox, radio button, checkbox, drop down list, submit and reset button etc.

The <Form> Tag :

Form is created using <Form>-----</Form> tag. All form elements are placed inside the body of the form. Forms cannot be nested.

Attribute of <Form> Tag :

  • Method : This attribute has two values GET or POST. The GET is a default method which appends the form-data to the URL in name/value pairs, which gets displayed on address bar upto 255 characters. The post method is used is used to send the data to the server for processing which is not displayed on address bar. So unlimited data can be transferred.

URL?name=value&name=value

  • Action : This attribute is used to specify the location/path or URL of the server where from information is to be submitted.
  • Name : This attribute is used to assign the name to form.

E.g. <form method="post" action="http://someserver/xyz/form name.asp">

In the above example the form's data is stored at assigned location in action attribute.

Text input fields or textbox :

Text field or input field allows the user to key in text into the field. <Input> tag is used to create a text/input or single line text box. It had no ending tag. <Input type="text"> is used to create single entry text box. By default the value of type is text.

Let's understand with an example

<Form>

First Name : <input type="text" name="firstname"> <BR>

Last Name : <input type="text" name="lastname">

</Form>

The above HTML code looks in a browser as follows :

First Name :
Last Name :

Attribute of <Input> Tag :

  • Size : This attribute assigns the limit to display size of a text box.

<Input type="text" size=35 name="xyz">

  • Maxlength : This limits the number of character that the user can key in a text field.

<Input type="text" name="xyz" maxlength="3> i.e. maximum 3 characters can be entered in the text box.

  • Name : It is used to assign the name to the textbox for processing of information contained in the text box, at the server end.
  • Value : It is assign the default value to the textbox.
  • Checked : Attribute is used for default selection of radio button and checkbox.
  • Type : It indicates the type of form object like text (default), radio, submit, reset, checkbox etc.

No comments:

Post a Comment

If you have any doubts regarding this please comment or email us.