21
Forms

Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Embed Size (px)

Citation preview

Page 1: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms

Page 2: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Form• An HTML form is a section of a document

containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.), controls.

• When a form is submitted, all fields on the form are being sent.

• The <form> tag tells the browser where the form starts and ends with </form>.

• You can add all kinds of HTML tags between the <form> and </form> tags.

Page 3: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Controls• Controls• Users interact with forms through named

controls.• control "control name" is given by its name

attribute. • Each control has both an initial value and a

current value, both of which are character strings.

Page 4: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Control types• Text Fields• Password Field• Text Areas• Radio Buttons• Checkboxes• Selection List• Button• …….

Page 5: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Text Fields• Text fields are used when the user to type

letters, numbers, etc. in a form.• Eg:• First name: • <input type="text" name="firstname">• <br>• Last name: • <input type="text" name="lastname">

Page 6: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Password Field• <input type="password" /> defines a• eg

Password: <input type="password" name="pwd" />

Page 7: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Text Areas

Text areas are used for multiple-line text entry. • The default size of the text box is 1 row by 20

characters. • Change the size using the COLS and ROWS attributes.• example of a text area with a text box 40 characters

wide by 7 rows• <TEXTAREA NAME="myarea" COLS="40" ROWS="7">• </TEXTAREA>

Page 8: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Radio Buttons• Radio Buttons are used when user to select

one of a limited number of choices.• <input type="radio" name="sex"

value="male”> Male• <br>• <input type="radio" name="sex"

value="female"> Female

Page 9: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Checkboxes • Checkboxes are used when the user to select

one or more options of a limited number of choices.

• <input type="checkbox" name="vehicle1" value="Bike">I have a bike

• <br>• <input type="checkbox" name="vehicle2"

value="Car">I have a car:

Page 10: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• The <select> tag is used to create a drop-

down list.• <select>

<option value=“popo">popo</option> <option value=“peepe">peepe</option> <option value=“monu">momu</option> <option value="akku">akku</option></select>

Page 11: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Button• To create a button• three types of buttons• submit buttons:• reset buttons:• push buttons:

Page 12: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Submit Button • submit buttons: When activated, a submit button submits a form.• A form may contain more than one submit button.• <input type="submit" /> defines a submit button.• A submit button is used to send form data to a server. • The data is sent to the page specified in the form's action

attribute. • The file defined in the action attribute• <form name="input" action=“data.php" method="get">

Username: <input type="text" name="user" /><input type="submit" value="Submit" /></form>

Page 13: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• Reset button• reset buttons: When activated, a reset

button resets all controls to their initial values.

• Used to reset all values in the form• <input type=reset>

Page 14: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• push buttons: Push buttons have no default

behavior.• Each push button may have client-side scripts

associated with the element's event attributes.• When an event occurs (e.g., the user presses

the button, releases it, etc.), the associated script is triggered.

• <input type="button" name="bb" value="button">

Page 15: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• HTML Forms• A form can contain input elements like text fields,

checkboxes, radio-buttons, submit buttons and more.

• The <form> tag is used to create an HTML form:• <form>

.input elements.</form>

Page 16: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• action URL Specifies where to send the form-data

when a form is submitted• Method • get and post• Specifies the method to use when sending form-

data• name name Specifies the name of a form• get Adds the form-data to the URL in URL?

name=value&name=value • post Sends the form-data as an HTTP post

transaction

Page 17: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• <html>• <head>• <title>popo</title>• </head>• <body bgcolor=black>• <center>• <table border=0 width=600>• <tr><td colspan=4 align=center><font size=16 color= white>Registration Form• <tr><td colspan=4 bgcolor=brown>&nbsp;• <tr><td align= right><font color=white size=3>First Name• <td><input type= text>• <tr><td align= right><font color=white size=3>Last Name• <td><input type= text>• <tr><td align= right><font color=white size=3>Address• <td><textarea cols=50 rows=5></textarea>• <tr><td align= right><font color=white size=3>Sex• <td><input type= radio name =s><font color=white size=3>Male<input type= radio name =s><font color=white

size=3>Female• <tr><td align= right rowspan=5><font color=white size=3>Hobby• <tr><td colspan=4><input type=checkbox> <font color=white size=3>Reading• <tr><td colspan=4><input type=checkbox> <font color=white size=3>Dancing• <tr><td colspan=4><input type=checkbox> <font color=white size=3>Sleeping• <tr><td colspan=4><input type=checkbox> <font color=white size=3>Watching TV• <tr><td align= right><font color=white size=3>State• <td><select>

Page 18: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms• <option value=“popo">popo</option>• <option value=“peepe">peepe</option>• <option value=“monu">momu</option>• <option value="akku">akku</option>• </select> • <tr><td align= right><font color=white size=3>District• <td><select>• <option value=“popo">popo</option>• <option value=“peepe">peepe</option>• <option value=“monu">momu</option>• <option value="akku">akku</option>• </select> • <tr><td align= right><font color=white size=3>User Name• <td><input type= text>• <tr><td align= right><font color=white size=3>Password• <td><input type=password>• <tr><td align= right><font color=white size=3>Confirm Password• <td><input type=password>• <tr><td><td align= center><input type=submit>&nbsp;&nbsp;<input type=reset>• <tr><td colspan=4 bgcolor=brown>&nbsp;• </table>• </center>• </body>• </html>

Page 19: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

REDIRECT VIA SUBMIT• <FORM METHOD="GET"

ACTION="index.htm"• <INPUT TYPE="submit" Name="redirect"

VALUE="To Title Page">• </FORM>

Page 20: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

SIMULATING BACK BUTTON• <FORM>• <INPUT TYPE="button" VALUE="Go Back"

onClick="history.back()">• </FORM>

Page 21: Forms. Form An HTML form is a section of a document containing normal content, special elements called controls (checkboxes, radio buttons, buttons, etc.),

Forms