210 likes | 223 Views
DePaul University. SNL 262 Web Page Design Forms ! - Chapt 7 Instructor: David A. Lash. HTML Forms. HTML Forms are used to: Gather survey information on web Submit passwords Structure queries on a database Submit orders Click Here for an example
E N D
DePaul University SNL 262 Web Page Design Forms! - Chapt 7 Instructor: David A. Lash
HTML Forms • HTML Forms are used to: • Gather survey information on web • Submit passwords • Structure queries on a database • Submit orders • Click Here for an example • http://www.depaul.edu/~dlash/extra/Webpage/examples/08survey.htm
HTML Forms • When submit a form it will be sent to a server script for processing HTML Form Program or database on Webserver (e.g., condor) Submit
HTML Form Elements Text Box Radio Buttons Check Box Select Box Text Area Submit/Reset button
Starting and Ending Forms • HTML forms are created by using the HTML <FORM> and </FORM> tags. • Within these tags, you place various HTML form elements, such as text areas, check boxes, and radio buttons. • For example, • <FORM ACTION=”http://nwswww.ih.lucent.com/~dlash/stuff.cgi” METHOD=”POST”> . . ß---(Your FORM elements here) . </FORM>
Two primary <FORM> arguments • <FORM ACTION=”http://perl-pgm.com/cgi-bin/stuff.cgi” METHOD=”POST”> • get appends the form arguments to the end of the Web address. • post sends the data as part of the body of the HTML document. • Will use post since get method may limit the amount of data you can send. ACTION= - Specifies the URL of the receiving file/program to start when the form is submitted METHOD= - Defines the argument format that will be used to send data to the receiving program/file.
Some Form Tag Examples < FORM METHOD=POST ACTION="http://hoohoo.ncsa.uiuc.edu/htbin-post/post-query" > • Sends the results to a program at http://hoohoo.ncsa.uiuc.edu/htbin-post/post-query. • <FORM METHOD="POST“ ACTION="mailto:dlash@condor.depaul.edu"> • Sends the results to via email to dlash@condor.depaul.edu • The email you get is a messy email (Click here for example.) For that reason, most sites don’t submit directly but execute a program first.
The Big Picture For Forms <FORM METHOD=POST ACTION="http://condor.depaul.edu/~dlash/save_it.php”> Your Form Here (Checklists, Text Boxes, Drop-down lists, buttons, etc) </FORM>
Creating Text Boxes • Text boxes are those input areas on a form where the customer can input free-format typing. For example click here.
Text Box: Format Please Enter Your Full Name <Input Type="Text" SIZE=20MAXLENGTH=30Name="fullname"> Where • Please Enter Your Full Name - is text to display immediately before the text box. • Input Type - A keyword that says how input will come in. You can say • "Text" - for text boxes with characters displayed in box as typed. • "Passwd" - For text boxes with asterisks "*" displayed in box as typed. • SIZE= Width of (in chars) the input box. • MAXLENGTH= - The max number of characters the user can type into box. • Name= The name identifier passed to the email program. (E.g., name="David Lash" )
Text Box: Format Please Enter Your Full Name <Input Type="Text" SIZE=20 MAXLENGTH=30 Name="fullname"> Where • Name= The name identifier passed to the email program. (E.g., name="David Lash" ) The resulting email might look like: fullname=Dave+Lash
Text Area: Format Just like text box but bigger. Click here http://www.depaul.edu/~dlash/website/TextInput.html <textarea NAME="UNIT_COMMENTS" ROWS=4 COLS=70 >Your comments here</textarea> • Name= The name identifier passed to the email program. (E.g., name=”UNIT_COMMENTS”) • ROWS, COLS = Number of cols and rows of text box
Check Boxes Check boxes are pre-defined optional input that you check. Click Here for example
Check Boxes: General Format Pick your favorite: <BR><INPUT TYPE=checkbox NAME="baseball” VALUE=“Like bball">Baseball <BR><INPUT TYPE=checkbox NAME="hockey" VALUE=“Like hockey">Hockey <BR><INPUT TYPE=checkboxNAME="soccer"VALUE=“Like soccer">Soccer Click Here for what it looks like: Pick your favorite: - This is a string of characters the shows up before check box. input TYPE="checkbox" - Says create a checkbox within the form. NAME=“soccer" - a name (e.g., soccer) to the checkbox that will be passed to the email software. VALUE=“Like soccer" - Specifies the initial value of the control (all set to “like soccer”) Note: you can include a checked attribute that checks the box initially.
Radio Buttons: General Format • Radio Boxes - (just like checked boxes - click here) http://www.depaul.edu/~dlash/website/radio1.html How is <b><i>Web Site Design Going</i></b>: <br><input TYPE="radio" NAME="variable1" VALUE=“sleep"> I get my extra sleep in class. <br><input TYPE="radio" NAME="variable1" VALUE=“lost"> I get so confused I get lost trying to find my car after class. <br><input TYPE="radio" NAME="variable1" VALUE=“gaveup">I gave up and copy my answers from my neighbor. <br><input TYPE="radio" NAME="variable1" VALUE=“great" checked> Great class can't wait for the movie. Variable1 is “set” to “great” if this item is picked Specifies to create a radio button Logical name is “variable1”
Selection Lists Here is an examplehttp://www.depaul.edu/~dlash/website/examle.html • Use <select> tag to create scrolling and pull-down pick lists. <select name="extras" size="3"multiple> <option selected> Electric windows </option> <option> AM/FM Radio </option> <option> Turbo Charger </option> </select> • name = the label shown from the mail. • size =number of selections shown • multiple = allow multiple options to pick • option = the option to pick • options selected = pre-selected option.
Submit Buttons • Submit - (send it on down - click here) http://www.depaul.edu/~dlash/website/radio1.html <INPUT TYPE="submit" VALUE="Submit"> <INPUT TYPE="submit" SRC="button.gif"> • Can also reset <INPUT TYPE="reset" VALUE="Erase"> <INPUT TYPE="reset" SRC="button.gif"> Create a submit button Put this text on the button. Use this gif image for button.
Putting it all together <html> <head> <title>Survey Form</title> </head> <body> <h1>Class Survey</h1> <FORM METHOD="POST" ACTION="mailto:dlash@condor.depaul.edu"> Name: <INPUT TYPE=input NAME="Name" > <br>Class:<INPUT TYPE=input NAME="Class" > <br>Class Evaluation: <BR><INPUT TYPE=radio NAME="Eval" VALUE="Y">Great <BR><INPUT TYPE=radio NAME="Eval" VALUE="Y">Average <BR><INPUT TYPE=radio NAME="Eval" VALUE="Y">Fair <BR><INPUT TYPE=radio NAME="Eval" VALUE="Y">Poor <br>Comments:<INPUT TYPE=input NAME="Comments" > <br><INPUT TYPE="submit" VALUE="Submit"> <INPUT TYPE="reset" VALUE="Erase"> </form> </BODY> </HTML> http://condor.depaul.edu/~dlash/extra/Webpage/examples/form1.html
Putting it all together <body> <h1>Class Survey</h1> <TABLE> <FORM METHOD="POST" ACTION="mailto:dlash@condor.depaul.edu"> <TR><TD> Name: </TD><TD> <INPUT TYPE=input NAME="Name" > </TD></TR><TR><TD> Class</TD><TD><INPUT TYPE=input NAME="Class" > </TD> </TD></TR><TR><TD> Class Evaluation: </TD><TD> <INPUT TYPE=radio NAME="Eval" VALUE="Y">Great <INPUT TYPE=radio NAME="Eval" VALUE="Y">Average <INPUT TYPE=radio NAME="Eval" VALUE="Y">Fair <INPUT TYPE=radio NAME="Eval" VALUE="Y">Poor </TD></TR><TR><TD> Comments</TD><TD><INPUT TYPE=input NAME="Comments" > </TD></TR><TR><TD> <INPUT TYPE="submit" VALUE="Submit"> </TD><TD> <INPUT TYPE="reset" VALUE="Erase"> </TR> </form> </BODY> http://condor.depaul.edu/~dlash/extra/Webpage/examples/form2.html
In Summary • We spoke about • What are forms? • The Form tag and arguments • How to create • Radio buttons • Checklists • Selection lists • Text boxes • Text areas • Submit buttons • How to format it all nicely.
Before We Leave • Homework Review • Test Review