Designing HTML Forms: HTML Forms are used to select different kinds of user input. Forms are used to pass data to a server. An HTML 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.
The <form> tag is used to create an HTML form:
Ex:-
<html>
<body>
<form method="POST" action="process.php">
Username : <input type=text name=user id=u value=Ram> <br>
Password : <input type=password name=pwd id=p > <br>
Age: <input type=text size=2 name=age id=a><br>
Sex: <input type=radio name=sex id=s1 value=M>Male
<input type=radio name=sex id=s2 value=F>Female<br>
Choose your Favourite Sport:
<input type=checkbox name=interest id=v1 value=crick>Cricket
<input type=checkbox name=interest id=v2 value=tenis>Tennis
<br>
Select your Country:
<select name=country>
<option value=ind> India </option>
<option value=uk> England </option>
<option value=us> USA </option>
<option value=aus> Australia </option>
</select>
<br>
Favourite Holiday Spot : <br>
<select multiple size=3 name=hspot>
<option value=africa> America </option>
<option value=europe> Europe </option>
<option value=asia> Switzerland </option>
<option value=australia> Australia </option>
</select>
<br>
Complete Address: <br>
<textarea name=addrs rows=5 cols=50></textarea> <br>
Resume : <input type=file name=resume id=res> <Br>
<input type=reset name=clear id=c value=Reset>
<input type=submit value="Continue">
<input type=button name=close id=s value=close>
</form>
</body>
</html>
Note : In text box we can give attribute maxlength to restrict the length of text. In a Text Box Maximum we can give 160 characters. In List Box we can select multiple items with using attribute multiple. Every Object should have name , id ( names can be same but id s must be unique). If you select radio buttons or check boxes or combo boxes or list boxes then the value will be returned, so value attribute is recommended for these objects.
op>---
No comments:
Post a Comment