Presentation is loading. Please wait.

Presentation is loading. Please wait.

HTML forms. Form elements  Forms consist of  Descriptions (explanation, instructions)  Places to enter information  free form (enter text)  check.

Similar presentations


Presentation on theme: "HTML forms. Form elements  Forms consist of  Descriptions (explanation, instructions)  Places to enter information  free form (enter text)  check."— Presentation transcript:

1 HTML forms

2 Form elements  Forms consist of  Descriptions (explanation, instructions)  Places to enter information  free form (enter text)  check boxes choose only one choose all that are appropriate  selection lists (control size of the display area) choose one choose all that are appropriate  Submit "button”  Clear form "button"

3 Form specific tags  Within the body of an html document:... All the formatting appropriate to the form It is possible to have more than one form on a page. Each must have a tag and a submit tag.

4 Getting input from the user  Forms exist to collect input from a user. The input is transmitted to a program to execute and a response comes back and is displayed for the user.  -- described by attributes.  -- there is a begin and end to this tag, but nothing appears between them.

5 Input types -- described by attributes. Examples Form activity buttons: Radio buttons, usually appear as list items: Cats are great I like dogs

6 Input - checkboxes  Checkboxes allow more than one selection   Examples: Jazz Classical Unlike the radio boxes, each choice is a separate variable with a value of “on” or “off”.

7 Input -- scrolling list Hamburgers Hot dogs Chicken Vegetarian meal Other options in select are multiple and size. Multiple allows more than one choice to be selected. Size determines how many of the options are visible when the form is displayed.

8 Responding to the form #!/usr/gnu/bin/perl print "Content-type: text/html\n\n"; print " Survey Echo \n"; print " \n"; print " Survey Echo \n"; # Get the input $buffer= ;

9 Responding to the form - 2 # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; }

10 Responding to the form -3 print " Hello, $FORM{myName}, thanks for filling in our survey "; print " Here is a summary of your responses "; print "\n\n"; print " Your favorite pets are $FORM{petkind}"; print "\n ";

11 Responding to the form - 4 print " In music, you like \&\#183\; "; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); if ($value eq "on") {print "$name \&\#183\; "}}; print "\n"; print " Your meal choices are $FORM{maincourse} or $FORM{second}.\n";

12 Responding to the form - 5 print " Your interests include the following: "; print "\&\#183\;\n"; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); #print "$name = $value\n"; $value =~ tr/+/ /; if ($name eq "interests") {print "$value \&\#183\; "}}; print "\n"; print" ";

13 Responding to the form - 6  print " Here is your comment: ";  print "$FORM{comments}";


Download ppt "HTML forms. Form elements  Forms consist of  Descriptions (explanation, instructions)  Places to enter information  free form (enter text)  check."

Similar presentations


Ads by Google