Saturday, 16 March 2013

html Forms


HTML Forms

Definition and Usage

HTML Forms is most important future in HTML. HTML Forms use to get a users information. its also say user is interactive with it. HTML Forms is a information tools to get information from the web surfer, such as: name, email address, address, phone number etc.
A form use to get information about user and information store that data into a web server.

Form Tags

Tag
Description
Defines a form for user input.
Defines an input field data.
Defines a push button
Defines a text-area (a multi-line text input box).
Defines a label to the description.
Defines a border to the input data.
Defines a caption name write into fieldset.
Defines a drop-down select list box.
Defines an option value in the drop-down box.


<input> Tag

The most used form tag is the <input> tag. This is the most commonly used tag within HTML forms. It give you to specify various types of user information fields such as text, checkboxes, radio buttons, Select Lists, Submit etc.
Attributes
Value
Description
type
"text" 
"button" 
"password" 
"file" 
"checkbox" 
"radio" 
"reset" 
"submit"
use input text value.
use to input button
use to text is convert password type.
use to browse file.
use to select option checkbox.
use to select in radio type.
use to input reset data.
use to input submit data.
value
"Value"
Specify the default value of element.
name
"Value"
Specify unique name for the input element.
size
"Number"
Define width of numbered(character) size input box.
maxlength
"Number"
Define maximum number(character) allow to enter input box.
checked

Specify input element to be checked when it is first time loaded.
alt
"Text"
Define input name to identify.
align
"left"
"right" 
"center"
Define input type align in HTML document.
src
"URL"
Define image open to mouse down submit.

<form> tag Action

Form Tag use to send the all form contain data (include text field, password field, radio button etc..) send to the defined server or Page or Database.
Example-Code:
<form action="form_submit.php" method="post" >
Your Feedback: <br />
 <textarea cols="65" rows="4" name="Feedback" >
I realy like your Web Service because....
</textarea/>
<input type="submit" value="Submit" name="Submit" />
</form>
Example-Result
Your Feedback:
 
Attributes
Value
Description
action
"sender address"
"Page" 
"Database_page"
Form all contain send to the defined link.
method
"get"
"post"
Form send Get Method to Get Form Contains.
Form send Post Method to Post Form Contains.


Example-Code:
<form>
First name:
<input type="text" name="FirstName:" size="10" maxlength="15" />
<br />
Last name:
<input type="text" name="LastName:" size="10" maxlength="15" />
</form>
Example-Result:
First name:  
Last name: 


Example-Code:
<form>
UserName:
<input type="text" name="FirstName" size="10" maxlength="15" />
<br />
Password:
<input type="password" name="LastName" size="10" maxlength="15" />
</form>
Example-Result:
UserName:  
Password:  


Example-Code:
Que.What is your favourites Web browser.
<form>
<input type="radio" name="browser" value="IE8" /> Internet Explorer 8
<input type="radio" name="browser" value="GC" /> Google Crome
<input type="radio" name="browser" value="FX"  /> Mozila Firefox
</form>
"browser"
Example-Result:
Que. What is your favourites Web browser.
 Internet Explorer 8 
 Google Crome 
 Mozila Firefox 


Example-Code:
Que.Select your hobby
<form>
<input type="checkbox" name="cricket" value="cricket" /> Cricket 
<input type="checkbox" name="watchtv" value="watchtv" /> Watch Tv 
<input type="checkbox" name="playgame" value="playgame" /> Play Game
<input type="checkbox" name="inserf" value="inserf"  /> Internet Surfing 
</form>
Example-Result:
Que.Select your hobby
 Cricket 
 Watch TV 
 Play Game 
 Reading 
 Internet Surfing


Example-Code:
<form action="login.asp" >
UserName:
<input type="text" name="FirstName" size="10" maxlength="15" />
<br />
Password:
<input type="password" name="LastName" size="10" maxlength="15" />
<br />
<input type="submit" value="Submit" name="Submit" />
<input type="reset" value="Submit" name="Submit" />
</form>
Example-Result:
UserName:  
Password: 
 


It is used to specify a text are or multi line text box. In a text area you can write an unlimited character. It is mostly use in user feedback, home address etc..
Example-Code:
<form>
Your Feedback: <br />
 <textarea cols="65" rows="4" name="Feedback" >
I realy like your Web Service because....
</textarea/>
</form>
Example-Result
Your Feedback:
Attributes
Value
Description
cols
"Specify_Number"
Define the Specify number of character visible in one line of text area.
rows
"Specify_Number"
Define the Specify number of line visible in text area.
name
"Message"
Specify unique name for the input element.


Selection List Fields

Example-Code
<form >
Select Your Hobby: <br />
<select name="hobby" >
<option value="cricket" selected>Cricket
<option value="WatchTV" selected>Watch Tv 
<option value="PlayGame" selected>Play Game
<option value="Reading" selected>Reading
<option value="Int" selected>Internet Surfing
</select>
</form >
Example-Result:
Select Your Hobby: 

<selection> Tag Attributes

Attributes
Value
Description
multiple
"space"
Define the Multiple select.
name
"Specify_Name"
Define the Specify name to select list description.
size
"Specify_Number"
Define the Specify number of item list size.

No comments:

Post a Comment