Searching...
Thursday 27 September 2012

Forms In Html

10:42 pm

Forms In Html

Forms In Html : 

              Html forms are used to select different kinds of user input.
A form is an area in a web page that can contain form elements like text fields, buttons,text area , radio buttons, list box,chek boxes , drop down list etc.
A form is defined with the <form> tag.
A form’s action attribute and submit button send e-mail from a form.
Attributes of Form :
1.       Action = url ; to specify where to submit the contents of the form when clients clicks on submit button.
2.       Method  ; to specify how to submit the contents of form to server. The values can be Get or Post ; default value of “method” is “GET”.

Difference between GET and POST :
1.       Get method is used for submiting only a limited amount of data .where as Post method is used for submiting more amount of data based on the configuration in php.ini.
2.       Get method submits only string type datawhere as Post method can submits any type of data.
3.       Get method submits the data as a query string i.e only with URL itself after ? where as post methods submits the data along with http request object.
4.       Name = reference of form.
Form Tags:
<form>  : defines a form for user input.
<input>  : defines an input field.
<textarea>  : defines a text area(multi-line text).
<lable>  : defines a lable to a control.
<fieldset>  : defines a field set.
<legend>  : defines a caption for field set.
<select>  : defines a selectable list.
<option>  : defines an option in the dropdown box.
<button>  : defines a push button.
Attributes of <input> :
1.       type : text/password/checkbox/radio/button/submit/reset/file/hidden etc.
2.       name : reference of form
3.       size  : display size of element.
4.       Value : default value.
5.       Maxlength : max allowed data size.
6.       Readonly
7.       Checked
8.       Disabled
   
   Student Registration Form :

Forms In Html :
  <html>
<body bgcolor =”pink”>
<h1 align = “center”>Registration Form</h1>
<hr color=”cyan” size=”9” width=”55%” align = “center”><br><br>
<form action =”regform.php” name=”frm1” method=”get”>
<table style=”font-family:verdana; font-size:18px; color: white; background-image:url(images/back1.jpg)” width=”55%”>
<tr height=”35px”>
<td>Name</td>
<td><input type=”text” name=”f1” size=”25” maxlength=”10”>
</td></tr>
<tr height =”35”>
<td> qualification</td>
<td><input type=”checkbox” name=”t2” value=”grad” checked>Graduate
<input type=”checkbox” name=”t3” value=”pg”>Post Graduate
</td>
</tr>
<tr height=”35”><td>Address</td>
<td> <textarea cols=”22” rows=”3” name=”t4’></textarea>
</td></tr>
<tr height=”35” >
<td>gender</td>
<td><input type=”radio” name=”t5” value=”M” checked> Male</td>
<input type=”radio” name=”t5” value=”F” >Female</td></tr>
<tr height=”35px” >
<td> Course Type</td><td><select name=”t6”>
<option> select course</option>
<option value=”online”> Online Training</option>
<option value=”class”>Class room Training</option>
<option value=”work”>Workshop</option>
</select>
</td>
</tr>
<tr height=”35”>
<td> Courses</td>
<td>
<select name=”t7” multiple>
<option value=”c”>C
<option value=”c++”>C++
<option value=”PHP”>PHP
</select>
</td>
</tr>
<td height=”35”>
<td>
<input type=”submit” value=”register”>
</td>
<td>
<input type=”reset” value=”clear”>
</td></tr></table></form>
</body>
</html>

0 comments:

Post a Comment