Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
45 views

Thehtml Form Tag: The Input Elements Go Here....

The HTML <form> tag defines an HTML form, which allows users to enter information that can be sent to and processed by a server. Forms contain form elements like text fields, checkboxes, radio buttons, and drop-down menus to collect user input. The <form> tag specifies attributes like action and method that control where the form data is sent and how it is sent. Common form elements include text fields, text areas, radio buttons, checkboxes, drop-down menus, and submit buttons.

Uploaded by

Naksha Ameena
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Thehtml Form Tag: The Input Elements Go Here....

The HTML <form> tag defines an HTML form, which allows users to enter information that can be sent to and processed by a server. Forms contain form elements like text fields, checkboxes, radio buttons, and drop-down menus to collect user input. The <form> tag specifies attributes like action and method that control where the form data is sent and how it is sent. Common form elements include text fields, text areas, radio buttons, checkboxes, drop-down menus, and submit buttons.

Uploaded by

Naksha Ameena
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

The H TM L form t ag

A form is an area that can contain form elements. Form elements are elements that allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.) in a form. A form is defined with the <form> tag. The input elements go here....

<FORM> </FORM>

Attri but es

Action Method This Attribute specifies the page which handles the input from the user. Usually, this will be a script or a CGI program which processes the data supplied by the user.

ACTIO N= "h andl erpag e"

Met hod

METHOD ="GET" | "POST" ( is either GET or POST.) In simple terms, if you use GET method, the input values are passed as part of the URL. If it is POST, the information is sent to the server as part of the data body and will not be visible in the URL box in the user's browser. If you don't specify the method, GET is taken by default.

The input item s

TextBox Text Field Radio Button Check Box Submit Button Reset Button

Tag Description <form> Defines a form for user input <input> Defines an input field <textarea> Defines a text-area (a multi-line text input control) <label> Defines a label to a control <fieldset> Defines a fieldset <legend> Defines a caption for a fieldset <select> Defines a selectable list (a drop-down box) <optgroup> Defines an option group <option> Defines an option in the drop-down box <button> Defines a push button

Te xt Box
HTML type= text size= maxlength= name= value= align= tabindex= EXPLANATION One line text field Characters shown. Max characters allowed. Name of the field. Initial value in the field. Alignment of the field. Tab order of the field.

<form> <input type="text"> </form>


<form> <input type="text" name="address"> </form>

<form> <input type="text" name="address" value="44 Cherry St"> </form>


<form> <input type="text" name="address" value="44 Cherry St" size="10"> </form>

<form> <input type="text" name="address" size="30" maxlength="10"> </form> Very similar to the type="text" is the type="password". It is exactly the same, except it displays **** instead of the actual input.

<fo rm> <inpu t t ype= "p assword "> </fo rm>

Text Box - Exam pl e


<html> <body> <form> First name: <input type="text" name="firstname"> <br><br><br> Last name: <input type="text" name="lastname"> <br><br><Br> </form> </body> </html>

Out put

Text Fiel d A rea


text area HTML rows= col s= name= tabi ndex = wrap= off vi rt ual physical
EXPLANATION Te xt a rea - s ever al lin es Rows in the field. Co lumn s in th e fie ld . Name of the field. Ta b o rder o f th e fi eld . Turns off linebreaking Shows lin ebre akin g, but e nds te xt a s e nte re d. Inserts linebreaks when

Exam pl e
<html> <body> <form> Your FeedBack Please : <br><br> <textarea cols="40" rows="5" name="myname"> </textarea> <br><br> Thank You </div> </form> </body> </html>

Radi o But ton


radio name= value= align= tabindex= checked Choose one - and only one option Name of the group. Value that is submitted if checked. Alignment of the field. Tab order of the field. Default check this field.

Radi oBut ton - Exa mpl e


<html> <body> <form> <input type="radio" name="Course" value="MCA"> MCA <br> <input type="radio" name="Course" value="MBA"> MBA </form> </body> </html>

Enabl e t he c he cke d opt ion for radi obut ton

CheckBox
<html> <body> <form> I have a bike: <input type="checkbox" name="vehicle" value="Bike" checked> I have a car: <input type="checkbox" name="vehicle" value="Car"> <br> I have an airplane: <input type="checkbox" name="vehicle" value="Airplane"> </form> </body> </html>

Drop D ow n Menu
<html> <body> <form action=""> <select name="Language"> <option <option <option <option </select> </form> </body> </html> value="C">C</option> value="C++">C++</option> value="Java">Java</option> value="VB">VB</option>

Addi ng a subm it but ton

After entering the data, the user presses the submit button which triggers the browser to send the data to the server. You can add a submit button to the form using the 'submit' input type. You can add a submit button to your html form using the following code

<INPUT TYPE="SUBMIT" NAME="name" VALUE="label"> <INPUT TYPE="Reset" NAME="rname" VALUE="rlabel">

You might also like