A html form is used to collect data or information from a web page or website.
Data collected under its control can be automatically submitted to a web server. Creating interactive websites for the internet requires capturing user input and processing it.
Captures the user’s input. A form element is enclosed in tags. HTML objects commonly used between tags are âtextâ, âpasswordâ, âbuttonsâ, âcheck boxâ, âradioâ, âresetâ, âsubmitâ, âhiddenâ, âselectâ, and âtext areaâ.Â
All form elements are accessible and their properties can be manipulated to control the functionality of the form at runtime. A form element has properties such as Name, Method, and Action.
Name: it will take the user name as a field.
Method: It will be used to send data captured from different pages. It can be done with Post or Get method. By default, it will take the get method as on the form.
Action:Â It will point to the address of the program where the server will process the data. Here it may use serverside scripting languages like ASP, PHP, or JSP.
<form name="form1" method="post" action="submit.php></form>
List of Form Elements/Properties
Elements are used with properties, and properties are defined according to the elements to be used.
- Input – <input><input> tag will be used within the <form></form> tags.
- Text:
<input type="text">
-
- Password:
<input type="password">
-
- Button:
<input type="button">
-
- Checkbox:
<input type="checkbox">
-
- Radio:
<input type="radio">
-
- Reset:
<input type="reset">
-
- Submit:
<input type="Submit">
-
- Hidden:
<input type="hidden">
-
- Select:
<select> <option> option 1 </option> <option> option 2 </option> </select>
-
- Text area:
<text area> text </text area>
-
- File:
<input type="file">
Element | Property |
Text
Password TextArea Button Radio Check Box Select Submit Reset Hidden File |
Name |
Text
Password TextArea Button Radio Check Box Select Submit Reset Hidden File Select |
Value |
Text
Password TextArea |
Default Value |
Radio
Check Box |
Checked |
Radio
Check Box |
Default Checked |
Radio | Length |
Radio | Index |
Select | |
Select | Text |
Examples
<input type="text" name="text1" value="search" size="20" maxlenght="64">
<input type="password" name="password" value="" size="20" maxlenght="20">
<textarea name="feedback" rows="20" cols="20"> Enter Feedback </textarea>
<input type="button" name="check" value="verify"> <input type="submit" name="btnsubmit" value="submit"> <input type="rest" name="btnreset" value="reset form">
<input type = âcheckboxâ name= âemployedâ value =âyesâ checked>
<input type="radio" name="number" value="1" checked>
<select name = âitemsâ size =â2â multiple> <option value = âFrench Friesâ Selected> French fries <option value = âHamburgersâ> Hamburgers <option value = âHotDogsâ> Hot Dogs </select>