forms. forms are used to receive information from the web surfer, such as: their name, email...

23
FORMS

Upload: rodger-strickland

Post on 04-Jan-2016

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

FORMS

Page 2: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

FORMS

Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc.

Form fields are objects that allow the visitor to enter information - for example text boxes, drop-down menus or radio buttons.

Page 3: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Different fields/objects in a form

Text fields Password fields Radio button Check box Drop down list Selection list Text area Submit button Email to

Page 4: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Text fields

password fields

Option/radio button

Check box

Drop down list

Text area

Submit button

CommerceScienceArts

stream Selection list

Page 5: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

FORMS 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. You can add all kinds of HTML tags between the <form> and

</form> tags.

To let the browser know where to send the content add the following properties to the <form> tag:

action=address method=post or method=get

The action specifies the URL to send the data to. The methods are the different methods for submitting data to the script.

"GET" should be used if and only if the form processing is a pure query form. There are, however, problems related to long URLs which make it necessary to use "POST" even for pure query cases.

Page 6: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Text Fields

<input> tag is used to tell the browser what type of field you want.

The <input> has a few attributes that you should be aware of.

type - Determines what kind of input field it will be. Possible choices are text, submit, and password.

name - Assigns a name to the given field so that you may reference it later.

size - Sets the horizontal width of the field. The unit of measurement is in blank spaces.

maxlength - Dictates the maximum number of characters that can be entered.

Page 7: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code:

<form method="post" action="mailto:[email protected]">

Name:

<input type="text" size="10" maxlength="40" name="name"> <br />

Password: <input type="password" size="10" maxlength="10" name="password"><br /><input type="submit" value="Send"> </form>

Simply change the email address to your own and you will have set up your first functional form!

Page 8: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Radio Buttons

Radio buttons are a popular form of interaction. You may have seen them on quizzes, questionnaires, and other web sites that give the user a multiple choice question.

value - specifies what will be sent if the user

chooses this radio button. Only one value will be sent for a given group of radio buttons

name - defines which set of radio buttons that it is a part of. Eg: shade and size.

Page 9: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code: <form method="post"

action="mailto:[email protected]">

What kind of shirt are you wearing? <br />

Shade: <input type="radio" name="shade" value="dark">Dark <input type="radio" name="shade" value="light">Light <br />

Size:<input type="radio" name="size" value="small">Small

<input type="radio" name="size" value="medium">Medium <input type="radio" name="size" value="large">Large

Page 10: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Check Boxes

Check boxes allow for multiple items to be selected for a certain group of choices. The check box's name and value attributes behave the same as a radio button.

Page 11: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code:

<form method="post" action="mailto:[email protected]">

Select your favorite cartoon characters.

<input type="checkbox" name="toon" value="Goofy">Goofy

<input type="checkbox" name="toon" value="Donald">Donald

<input type="checkbox" name="toon" value="Bugs">Bugs Bunny

<input type="checkbox" name="toon" value="Scoob">Scooby

Doo

Page 12: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Drop Down Lists

Drop down menues are created with the <select> and <option> tags. <select> is the list itself and each <option> is an available choice for the user.

Page 13: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code:

<form method="post" action="mailto:[email protected]"> College Degree? <select name="degree"> <option>Choose One</option> <option>Some High School</option> <option>High School Degree</option> <option>Some College</option> <option>Bachelor's Degree</option> <option>Doctorate</option> <input type="submit" value="Email Yourself"> </select> </form>

Page 14: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Selection Forms

Yet another type of form, a highlighted selection list. This form will post what the user highlights. Basically just another type of way to get input from the user.

The size attribute selects how many options will be shown at once before needing to scroll, and the selected option tells the browser which choice to select by default.

Page 15: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code:

<form method="post" action="mailto:[email protected]"> Musical Taste <select multiple name="music" size="4"> <option value="emo" selected>Emo</option> <option value="metal/rock" >Metal/Rock</option> <option value="hiphop" >Hip Hop</option> <option value="ska" >Ska</option> <option value="jazz" >Jazz</option> <option value="country" >Country</option> <option value="classical" >Classical</option> <option value="alternative" >Alternative</option> <option value="oldies" >Oldies</option> <option value="techno" >Techno</option> </select> <input type="submit" value="Email Yourself"> </form>

Page 16: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Text Areas

Text areas serve as an input field for viewers to place their own comments onto. Forums and the like use text areas to post what you type onto their site using scripts. For this form, the text area is used as a way to write comments to somebody.

Rows and columns need to be specified as attributes to the <textarea> tag. columns reflects how many characters wide the text area will be and the rows the height of the text box

Page 17: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Attribute of textarea Wrap has 3 values. wrap=

"off" "virtual" "physical"

Virtual means that the viewer will see the words wrapping as they type their comments, but when the page is submitted to you, the web host, the document sent will not have wrapping words.Physical means that the text will appear both to you, the web host, and the viewer including any page breaks and additional spaces that may be inputed. The words come as they are.Off of course, turns off word wrapping within the text area. One ongoing line.

Page 18: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

HTML Code:

<form method="post" action="mailto:[email protected]"> <textarea rows="5" cols="20" wrap="physical" name="comments"> Enter Comments Here </textarea> <input type="submit" value="Email Yourself"> </form>

Also note that any text placed between the opening and closing textarea tags will show up inside the text area when the browser views it.

Page 19: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Submit

Generally, the submit button should be the last item of your form .

Here is a list of important attributes of the submit: In addition to adding the submit button, we must

also add a destination for this information and specify how we want it to travel to that place.

method - We will only be using the post functionality of method, which sends the data without displaying any of the information to the visitor.

action - Specifies the URL to send the data to. We will be sending our information to a fake email address.

Page 20: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Send email from a form

<form action="MAILTO:[email protected]" method="post" enctype="text/plain">

<h3>This form sends an e-mail to W3Schools.</h3> Name:<br> <input type="text" name="name" value="yourname" size="20"> <br> Mail:<br> <input type="text" name="mail" value="yourmail" size="20"> <br> Comment:<br> <input type="text" name="comment" value="yourcomment" size="40"> <br><br> <input type="submit" value="Send"> <input type="reset" value="Reset">

Page 21: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

Reset button When a visitor clicks a reset button, the entries are reset to the default

values.

Reset attributes  name,  value,   align

The name setting adds an internal name to the button so the program that handles the form doesn't confuse the button with the other fields.

The value setting defines what is written on the button.

The align setting defines how the button is aligned.Valid entries are: TOP, MIDDLE, BOTTOM, RIGHT, LEFT, TEXTTOP, BASELINE, ABSMIDDLE, ABSBOTTOM.

The tabindex setting defines in which order the different fields should be activated when the visitor clicks the tab key.

Page 22: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

IMAGE BUTTON

Image buttons have the same effect as submit buttons. When a visitor clicks an image button the form is sent to the address specified in the action setting of the <form> tag.

image  name=  src=  align=  border=  width=  height=  vspace=  hspace=  tabindex=

Page 23: FORMS. Forms are used to receive information from the web surfer, such as: their name, email address, credit card, etc. Form fields are objects that allow

<lable>

Defines a label to a control. If you click the text within the label element,  it is supposed to toggle the control.