Saturday 28 September 2013

HTML Form Elements with Attributes

Here are the Input Tags that are used in making a form. Forms are very important element of HTML. They are used in almost every website. They are used to collect data from the client. They are used in Admin Panel in Dynamic Website for many reasons and so on. So learning HTML Form Elements is very important for an HTML learner. For this we are going to give you the list of Input Tags for a form. Here we have given the Input Tags with their mostly used attributes.

Tags Used in a Form
<FORM
name=“nameOfTheForm”
method=“get” or “post”
action=“URL”

> 
Elements of the form
</FORM>

Single-Line Text Input Field
<INPUT
type=“text”
name=“fieldName”
size=“widthInCharacters”
maxlength=“limitInCharacters”
value=“initialDefaultValue”
> 
Hidden Input
<INPUT
type=“hidden”
name=“fieldName”
value=“value”
> 
Submit Button Input
<INPUT
type=“submit”
name=“buttonName”
value=“displayedText”
> 
Multi-Line Text Input Area
<TEXTAREA
name=“areaName”
cols=“widthInCharacters”
rows=“numberOfLines”
> 
Initial default value
</TEXTAREA>

Password Input Field
<INPUT
type=“password”
name=“fieldName”
size=“widthInCharacters”
maxlength=“limitInCharacters”
value=“initialDefaultValue”
> 
Checkbox Input Element
<INPUT
type=“checkbox”
name=“checkboxName”
checked
value=“checkedValue”
> 
Check is used for setting a default value for a check box. When first the user will see the checkbox, it will be checked.
Radio Button Input Element
<INPUT
type=“radio”
name=“radioButtonName”
checked
value=“selectedValue”
> 
Check is used for setting a default value for a radio button. When first the user will see the radio button, it will be checked.

Select from a (Drop Down) List
<SELECT
name=“listName”
size=“numberOfDisplayedChoices”
multiple
> 
<OPTION value=“value1”> text1 </OPTION>
<OPTION value=“value2” selected> text2 </OPTION>
<OPTION value=“value3”> text2 </OPTION>
</SELECT>
Multiple is used to select multiple options at the same time.
Upload Input Element
<INPUT
type=“file”
name=“buttonName”
value=“nameOfSelectedFile”
enctype=“fileEncodingType”
> 
Reset Button Input Element
(Resets the contents of a form to default values)
<INPUT
type=“reset”
value=“dispalyedText”
> 
 The following form is a simple form which has the capability of uploading a file. By using the <input type=”file” /> field we can upload a file from over system to the server. This is mainly used in forms for Uploading Pictures or Uploading CV etc.

<form
name=“uploadForm”
method=“post”
action=“uploadScript”
<input
type=“file”
name=“uploadFile”
enctype=“multipart/form-data”
> 
<input
type=“submit”
name=“submit”
value=“Upload”
> 
</form>



No comments:

Post a Comment