+ All Categories
Home > Education > HTML Form Part 1

HTML Form Part 1

Date post: 14-Jan-2015
Category:
Upload: teresa-pelkie
View: 647 times
Download: 0 times
Share this document with a friend
Description:
 
46
1 Forms Tutorial 6 – Part A
Transcript
Page 1: HTML Form Part 1

1

Forms

Tutorial 6 – Part A

Page 2: HTML Form Part 1

2

Forms

• HTML language creates the form elements

• Data entered in the form element can only

be retrieved or processed through a

program or script running on a Web Server

Page 3: HTML Form Part 1

3

Server technologies that work with HTML forms

- CGI / PERL

- ASPX

- PHP

- JSP

Page 4: HTML Form Part 1

4

Page 5: HTML Form Part 1

5

The form tag

<form name=“my_form” id=“my_form”>

form elements here

– HTML allowed here also

</form>

Page 6: HTML Form Part 1

6

The form tag

<form name=“xyz” id=“xyz”

action=“script “

method= “post or get“

enctype=“ “

target=“ “>

</form>

Page 7: HTML Form Part 1

7

input tag

<input type=“type”

name=“name”

id=“id”

value=“user entry” />

identifies the element to the server

used for CSS /JavaScript

Page 8: HTML Form Part 1

8

input tag

<input type=“type”

name=“name”

id=“id”

value=“some_value” >

Every element has a “name” to identify it

The user enters a “value”

Page 9: HTML Form Part 1

9

name / value pairs are sent to the server when the form is submitted

Page 10: HTML Form Part 1

10

Text box

<input type=”text"

name=“last_name" id=“last_name” >

value – what the user enters

Page 11: HTML Form Part 1

11

Text box Attributes

<input type=”text" name=“last_name " id=“last_name "

size="number of characters “ maxlength=" maximum_characters “ >

Page 12: HTML Form Part 1

12

label tag

<label for=“id”> some text</label>

• Associates a description with a form element

• Used for accessibility and JavaScript

Page 13: HTML Form Part 1

13

label tag

Page 14: HTML Form Part 1

14

radio buttons / option buttons

<input type=”radio"

name=“name" id=“id"

value= “value“ >

Page 15: HTML Form Part 1

15

radio buttons

<input type=”radio"

name=“name" id=“id"

value= “value“ >

Must code in a value

The value identifies the choice

Page 16: HTML Form Part 1

16

radio buttons

Occur in groups

Must have the same name

Must have different values

Mutually exclusive

Page 17: HTML Form Part 1

17

Checked by Default

<input type=”radio"

checked = “checked” />

<input type=”radio"

checked >

Page 18: HTML Form Part 1

18

check box

<input type=”checkbox"

name=“name" id=“id"

value= ‘value“ >

Must code in a value

The value identifies the choice

Page 19: HTML Form Part 1

19

check boxes

Occur in groups

Can have the same name

Must have different values

Can check all choices

Page 20: HTML Form Part 1

20

check box group – same name

<input type=”checkbox" name=“os” id=“os1” value= “WinXP“ >

<input type=”checkbox" name=“os” id=“os2” value= “Windows2000“ >

Page 21: HTML Form Part 1

21

check box group – different name

<input type=”checkbox" name=“os1” id=“os1” value= “WinXP“ >

<input type=”checkbox" name=“os2” id=“os2” value= “Windows2000“ >

Page 22: HTML Form Part 1

22

Force a check

<input type=”checkbox" checked = “checked” />

<input type=”checkbox" checked >

Page 23: HTML Form Part 1

23

missing value attribute

<input type=”checkbox"

name=“xyz”

id=“xyz” />

If checked – will return “on” as the “value”

Page 24: HTML Form Part 1

24

select / drop down list

Has one name attribute

Must have different values

“value” attribute is optional

Can check multiple choices

Page 25: HTML Form Part 1

25

A Selection List

<select name=“job“ id=“job”>

<option>Please select one</option>

<option>Programmer </option>

<option>Database Manager </option>

</select>

Text will be “value”

Page 26: HTML Form Part 1

26

A Selection List

<select name=“job“ id=“job”>

<option value="none"> Please select one</option>

<option value ="pgmr">Programmer </option>

<option value =“dbm">Database Manager </option>

</select>

Page 27: HTML Form Part 1

27

A Multiple Selection List

<select name=“job“ id=“job” multiple=“multiple”>

<option>CEO</option>

<option>Director</option>

<option>Supervisor</option>

</select>

All options are shown

Page 28: HTML Form Part 1

28

Multiple Selection List with set options visible

<select name=“job“ id=“job” multiple size=“3”>

<option>CEO</option>

<option>Director</option>

<option>Supervisor</option>

</select>

3 options are shown

Page 29: HTML Form Part 1

29

selected by default

<select name=“job“ id=“job”>

<option value="none"> Please select one</option>

</select>

Automaticallyselected

Page 30: HTML Form Part 1

30

force a choice

<option value ="pgmr” selected=“selected”> Programmer </option>

<option value ="pgmr” selected> Programmer </option>

Page 31: HTML Form Part 1

31

Option Groups <optgroup>

Page 32: HTML Form Part 1

32

Textarea element

Multi-line text box

Uses fixed width font

Sized using rows and columns

Page 33: HTML Form Part 1

33

Textarea <textarea>

<textarea rows="4" cols="50" name="" id="">

</textarea>

Page 34: HTML Form Part 1

34

fieldset and legend elements

Logically groups elements

Draws a box

The <legend> tag defines a caption

for the fieldset element

Page 35: HTML Form Part 1

35

<fieldset> <legend> </legend>

form elements</fieldset>

Page 36: HTML Form Part 1

36

tabindex / accesskey attributes

Assigns a tabbing order

Assigns a keyboard shortcut

Page 37: HTML Form Part 1

37

tabindex / accesskey attributes<label for=“name">Name (Alt-n):</label>

<input type="text“ name=“name“ id="name“ tabindex="1" accesskey="n">

Page 38: HTML Form Part 1

38

readonly / disabled attributes

<input type=” ” readonly=”readonly” />

<input type=” ” disabled>

Page 39: HTML Form Part 1

39

Other input elements

<input type=”password" ><input type=”hidden" >

<input type=”image" ><input type=”file" >

<input type=”submit" ><input type=”reset" >

Page 40: HTML Form Part 1

40

type=“hidden” hidden fields – used to send information to server

Page 41: HTML Form Part 1

41

type=“file”

Page 43: HTML Form Part 1

43

Three Types of Buttons

• Command button

– used with JavaScript

• Submit button

• Reset button

Page 44: HTML Form Part 1

44

Submit Button

<input type=”submit" name=“" id=““ value= ‘what_it_says” >

Calls the action of the form

Not really needed

Page 45: HTML Form Part 1

45

Reset Button

<input type=”reset" name=“" id=““ value= ‘what_it_says“ >

Clears all the values in the form

Not really needed

Reset

Page 46: HTML Form Part 1

46

Command Button

<input type=”button" name=“" id=““ value= ‘what_it_says“ >

Used with JavaScript

Click Me


Recommended