Things you want to know about websites

 

HTML Forms

Forms enable you to collect informtion from your visitors. Forms are used for getting feedback, receiving queries or getting search queries to perform a search operation.

Basic information about forms in presented in this guide. You can see more information on forms in the advanced section.

Creating a Form

A form is created by <form> and </form> tags.

Example

The general form of an Html Form is,

<form method="post" action="action.php" >

Form contents or Form elements

</form>

Method and Action attributes

The method attribute takes the values "get" or "post". The action attritube gives the name and location of the script that will process the form data. In the above example the script is action.php and the method used is post.

Text Fields

Text fields are created by using <input> tag. An input element has the form,

<input type="text" name="name" size="20" value="default"/>

The value (text) supplied to the name attribute is used by the processing form as a form variable.
The value of the size attribute describes the text field size in characters that are displayed on the screen.
The value attribute gives the text field a default value.

Example

<form method="post" action="" >
Name:<input type="text" name="name" size="30" value="Type your Name"/>
Email :<input type="text" name="email" size="30" value="Type your Email"/>
</form>

gives,

Name:
Email :

You can also specify a limit on the number of characters that can be entered by using maxlenght attribute.

Larger text areas

If you want to provide the visitors a larger text area to write, you can use the <textarea> element.

Example

<form method="post" action="action.php" >
Message:
<textarea name="message" row="2" cols="40">Enter you message</textarea>
</form>

gives,

Message:

Submit & Reset Button

The submit button when clicked, accepts the filled out data and calls the action script. You can create a submit button by using type="submit".

The reset button clears the information filled in the from. You can create a reset button by using type="reset".

Example

<form method="post" action="" >
Name:<input type="text" name="name" size="30" value="Type your Name"/>
Email :<input type="text" name="email" size="30" value="Type your Email"/>
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>

gives,

Name:
Email :

Bookmark or Add to Favourites

Next:

Html-Doctype and Flavors

Related:

Html-Frames
Html-Forms Advanced

Link to this page :

Copy and paste the following code in an html document to link to this page,