+ All Categories

Forms

Date post: 24-Jan-2016
Category:
Upload: ovidio
View: 29 times
Download: 0 times
Share this document with a friend
Description:
Forms. Making your HTML Page Interactive. Form Tag. First, tell the browser you are creating a Form There are other attributes you can add, but we’ll just start with the basics. Your code should look like this:. learning forms - PowerPoint PPT Presentation
Popular Tags:
27
Forms Making your HTML Page Interactive
Transcript
Page 1: Forms

Forms

Making your HTML Page Interactive

Page 2: Forms

Form Tag First, tell the browser you are creating a

Form <form></form> There are other attributes you can add,

but we’ll just start with the basics.

Page 3: Forms

Your code should look like this:<html><head><title>learning forms</title></head><body><form>

</form></body></html>

Page 4: Forms

Types of input You must define what type of input you

are requiring your viewer to do Text Radio Check Simple Drop Down Boxes Text Area

Page 5: Forms

Syntax First define the input type Next name the input The last step will depend on which type of

input you are using For text, it will be size (how large to make the

box to answer) For radio and checkboxes, it will be value

(what value the button has)

Page 6: Forms

Text Input Text input is used to collect single line of text from the user like name,

email address etc. It is the most commonly used input type.

A text input item can be defined like this:

<INPUT TYPE="TEXT“>

TYPE="TEXT" attribute tells the browser that a single line text input box should be created.

NAME="FirstName"  defines the name of the field. This name will be used at the server side to identify this input item.

<input type=“text” name=“First Name”>

SIZE="lengthChars“ is the length of the input text box, in number of characters.

<input type=“text” name=“First Name” size=“30”>

Page 7: Forms

Let’s put it in a table<table width=“100%”><tr><td><input type=“text” name=“First Name”

size=“30”></td></tr>What would the next td probably be?

Page 8: Forms

Text Input<form>

First name:<input type="text" name="firstname" size=20><br />Last name:<input type="text" name="lastname" size=30></form>

Example 1

Notice that we put what the field should contain before defining the box after it.

Page 9: Forms

Radio ButtonsYou will use these when you only want your viewer to be able to

make one choice.

<INPUT TYPE="RADIO" NAME="name" VALUE="valueOfThisItem">

Buttons in the same set will have the same name. For example, if you are asking someone to rate an item as

excellent, good, fair, poor, the name of your buttons could be RATE.

Here’s an example:

<INPUT TYPE="RADIO" NAME="rating" VALUE="excellent">Excellent !!! <BR>

Page 10: Forms

Radio Buttons <input type="radio" name="sex"

value="male"> Male<br ><input type="radio" name="sex" value="female">Female

Example 2

Page 11: Forms

Checkboxes Checkboxes are used when you want the user to select one or

more options of a limited number of choices. For example, if you wanted someone to choose which items they

had previously bought from your company. The name value will be the same for each checkbox:

<INPUT TYPE="CHECKBOX" NAME=“product" VALUE="checkboxValue">

Here’s an example:<INPUT TYPE=“checkbox" NAME=“product" VALUE=“MP3">MP3

player

Page 12: Forms

Checkboxes

I have a bike:<input type="checkbox" name="vehicle" value="Bike">Bike<br>I have a car:<input type="checkbox" name="vehicle" value="Car">Car <br>I have an airplane:<input type="checkbox" name="vehicle" value="Airplane">Airplane<br>

Example 3

Page 13: Forms

Syntax for Drop Downs A little different than the other inputs. You use select and option value.

Page 14: Forms

Drop Downs A drop down is a selectable list. This time, you don’t have to use the

<input form> tag. Just use <select name=“category”>. Then define each choice in the drop down

use the <option value=“_____”>NAME </option> for each choice in the drop down

Finally, use the ending tag </select>.

Page 15: Forms

Simple Drop Down Boxes<select name="cars"><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="fiat">Fiat</option><option value="audi">Audi</option></select>

Example 4

Page 16: Forms

Syntax for Textarea Different still than the other input groups. Textarea as a paired code is all you need. <textarea></textarea> You only define values or name it if you

want to.

Page 17: Forms

Text Area A user can write text in the text-area. In a

text-area you can write an unlimited number of characters on multiple lines.

<textarea rows=“10” cols=“30”></textarea>

This would give you 10 rows with about 30 characters each for a viewer to write comments.

Page 18: Forms

Text Areas<textarea rows=“10” cols=“30”></textarea>

Example 5

Page 19: Forms

Product Registration Page<table width=“50%”><h1>product registration</h1><Form name =Request>

<table width="50%" border="0"> <tr><td>First Name</td><td><input

width=“30”>Last Name<input size=30></tr> <tr><td>Address<td> <input size=70></tr> <tr><td>City<td><input size=30></tr> <tr><td>State<td><input size=2></tr> <tr><td>Zip<td><input size=5></tr></table> <br>

Page 20: Forms

Product Registration Radio Button<tr><td>What item did you purchase?<br><input type=“radio” value=“purchases” name=“CD>CD Player<br><input type=“radio” value=“purchases” name=“tv>Television<br><input type=“radio” value=“purchases” name=“phone”>Telephone<br><input type=“radio” value=“purchases” name=“cell”>Cell Phone<br><input type=“radio” value=“purchases” name=“computer”>Computer<br>

</tr>

Page 21: Forms

Product Registration Dropdown <select name=“products” Option values are warranty, accessories,

hands free and nothing extra, please End with </select>

Page 22: Forms

Text area 10 rows and 30 columns

Page 23: Forms

Next Lesson In the next lesson, we will learn to create

buttons to submit or send to an email address.

Page 24: Forms

Adding a Submit Button sent to email<form method="post"

action="mailto:[email protected]"> <br><input type="submit" value="Send"> </form>

Page 25: Forms

Adding a submit button <form method="get" action="http://address

you want to link to"><input type="submit" value="click here"></form>

This is what it would look like: Add color to your button: <FORM METHOD="get"

ACTION="http://www.lissaexplains.com"> <INPUT TITLE="submit" TYPE="submit"

STYLE="background:#00ff00" VALUE="Click Here"></FORM>

Page 26: Forms

Your Turn Creating a simple form for a guestbook.

Please sign my guestbook. Use the input type element. Input types available: Textbox For a larger

area textbox for comments, etc. Radio Buttons Checkboxes Drop Down Boxes Buttons to submit answers or reset form

You will create a link in your All About me page for visitors to sign your guestbook

Page 27: Forms

Your turn, AGAIN Create an information form for the White

Plains Alumni Association to use in planning future class reunions.


Recommended