Forms

what is form ?

Forms are the most popular way to make web pages interactive. Like forms on paper, a form on a web page allows the user to enter requested information and submit it for processing.

A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend, and label elements.

Syntax

<form>

</form>

Input Elements

Text fields

<input type=”text” />

Example

<form>
First name: <input type=”text” name=”firstname” /><br />
Last name: <input type=”text” name=”lastname” />
</form>

Text Area

<TEXTAREA NAME=”comments” COLS=40 ROWS=6></TEXTAREA>

Text area requires cols and rows attribute

cols – how many characters wide
rows – how many rows

Example

<form>
First name: <input type=”text” name=”firstname” /><br />
Last name: <input type=”text” name=”lastname” />
Address: <textarea name=”address” cols=40 rows=6></textarea>

</form>

Once filling our information we have to submit form to the corresponding people , like that we have to submit form to the server

submit buttons

syntax :
<input type=”submit” value=”Submit” />

Where the form will submit?Where the data will collect ?

Normally when we filled form we send to corresponding people like that we have set the action attribute to the form .

ACTION – The data is sent to the page specified in the form’s action attribute.

METHOD specifies the method of transferring the form data to the web server. METHOD can be either GET or POST.

Example

<form action=”html_form.asp” method=”get”>
First name: <input type=”text” name=”firstname” /><br />
Last name: <input type=”text” name=”lastname” />
Address: <textarea name=”address” cols=40 rows=6></textarea>
<input type=”submit” value=”Submit” />
</form>

Source:w3schools

Posted in Html