LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit...

28
LESSON 10 UNIT K FORMS

Transcript of LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit...

Page 1: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

LESSON 10 UNIT K

FORMS

Page 2: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

WHY FORMS?

Free-form – input that is unstructured and does not limit choices. •For example, lets say you ask clients to e-mail you the information about your pet so that your can book the pet a spot in the kennel.

• E-mail number 1 - Bowser is a five year old grey and white female and weighs about 13 pounds. Bowser will be staying 3 days starting next Friday.

• E-mail number 2 - Bubba is our family dog. Bubba is a very gentle brown Labrador Retriever. Lately Bubba has had some medical problems but it should not be during the stay on the upcoming holiday weekend.

•Do you know the gender, type of animal, status of shots or even exactly which days and nights the animal will be at the kennel?

2

Page 3: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

FORM ADVANTAGES

• User does the work.• Can require information• Can limit choices• Can validate input• Can give default values• Can put information into discrete pieces – “chunks”

• 2201989 Birthdate• 02 20 1989 Better • 6025551234 Phone number• 602 555 1234 Better• PatJones• Pat Jones

3

Page 4: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

WHICH IS BETTER?

• Which is better a persons age or their date of birth?

• ANSWER: Date of birth because it does not change and age can be calculated.

• Derived data - data value can be computed based upon other data.

• More accurate. Why?

4

Page 5: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

WHERE TO START?

• What is the purpose of the form?• How will the information be used?• What type of data?

• Yes/no, numbers to what decimal, abbreviations, codes

• How discreet? First name, initial, last name• Break down into multiple has advantages

and disadvantages.

• Talk to the users if possible.

5

Page 6: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

WHERE TO START?

• Design on paper first.• Put a title on the form • Place a unique identifier of the form

• (usually in top right corner or in the footer).

• Provide instructions and explanations.

• Every input should have a label.

6

Page 7: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

WHERE TO START?

• Put related fields together.• Order should be what users expect.• Logical flow

left right top Vbottom

• Place a field for questions or comments at the bottom of the form.

7

Page 8: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

FORM ESSENTIALS

• Define the form with form tags<form> </form>

Your entire form MUST be within the form tags!

• Add input controls – they all must be within the form tags.

• Add action buttons – at bottom of form before the end form tag.

8

Page 9: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

Without css

9

Page 10: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

With css

10

Page 11: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

• FIELDSET – Group of form elements• LABEL – Descriptive text• LEGEND – Descriptive title for a fieldset• How many fieldsets in the following code?• Within contactinfo, what is the first legend

and what is the first label?

11

Page 12: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

INPUT CONTROLS - TEXTFIELD

• Type is text for the first input, type is email for the second input

• name= is crucial for input• id= is crucial for css• Placeholder gives direction

12

Page 13: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

INPUT FROM A FORM

What is submit is the name attribute of a field with the associated value.

13

Page 14: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

HOW DOES A TEXTFIELD GET ITS SIZE?

In the css file#nameinput, #emailinput {width: 30em; maxlength: 60} #phoneinput {width: 12em; }

14

Page 15: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

INPUT CONTROLS - CHECKBOXES

• Why is value crucial? 15

Page 16: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

INPUT CONTROLS – OPTION BUTTONS

In order for buttons to work, each group MUST use the same value for name.Checked indicates the default.

16

Page 17: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

SUPPOSE YOU WANTED TO KNOW WHAT COUNTY THEY LIVE IN.

• How many counties in Arizona?• 15

• Which state has the fewest counties?• Alaska has 8 and Hawaii has only 5• But the trick answer is Louisiana has zero counties and 64

parishes

• Which state has the most counties?• Texas has 254

• Use Drop down menu for a selection of one from many. Limits choices and controls input.

17

Page 18: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

SUPPOSE YOU WANTED TO KNOW WHAT COUNTY THEY LIVE IN.

18

Page 19: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

INPUT CONTROLS PROVIDE A VARIETY OF INPUT TECHNIQUES.

19

Page 20: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

ADDITIONAL INPUTS

Textarea – multi-column text area.

20

Page 21: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

ADDITION ITEMS

21

Page 22: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

ADDITION ITEM REQUIRING INPUT.

New attribute in HTML5Can be done with a script – javascript.

<legend><span>Contact Information</span></legend><label>Name<input type="text" name="name" id="nameinput" required="required" placeholder="First and last name" /></label>

22

Page 23: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

EVEN MORE ADDITIONAL ITEMS

23

Page 24: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

<fieldset id="submitbutton">

<input type="submit" id="submit“

value="Add to Cart" />

</fieldset>

ACTION BUTTONS

24

Page 25: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

MORE ABOUT BUTTONS

On the begin form tag you can indicate an action and a method for how the form is submitted.

25

Page 26: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

SUBMIT BUTTON

• “action” attribute used to specify name and location of script that will accept form data

• “method” attribute used to indicate how data should be submitted

• On the form tag you might have:<form action=“my_form.asp" method="get"> or<form method="post" action="http://www.sample.com/cgi-bin/formmail.cgi">

26

Page 27: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

27

Page 28: LESSON 10 UNIT K FORMS. WHY FORMS? Free-form – input that is unstructured and does not limit choices. For example, lets say you ask clients to e-mail.

28