Presentation is loading. Please wait.

Presentation is loading. Please wait.

HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.

Similar presentations


Presentation on theme: "HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back."— Presentation transcript:

1 HTML Form Widgets

2 Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back to the web server Forms allow web servers to generate “dynamic” web pages, and to “personalize” pages for the individual user Forms contain labels, text boxes, buttons, etc.

3 Review: CGI Programs After the user enters the information, they press the “submit” button to send the information to the web server The attribute tells the web browser where to send the information The action URL is the address of a CGI program that is running on a web server The CGI program reads the user input sent by the browser, and then sends a dynamically generated HTML page back to the browser

4 Client-side Scripting Not all HTML forms contact a CGI program on a web server These forms execute entirely on the client computer The “program” is included as part of the HTML page that contains the form, and is executed by the browser This program is sometimes called a “script”, and is written in a programming language named JavaScript Many web sites use a combination of CGI programs and client-side scripting

5 Pizza Order Demo

6 HTML Form Widgets Text Box Button Check Box Radio Buttons Text Area Selection List

7 Text Box Attributes –size (the width of the text box in characters) –maxlength (the maximum number of characters the user is allowed to type in the text box) –name (the name of the variable used to reference the text box from JavaScript) –value (the string currently in the text box)

8 Text Box Demo Text Box Title:

9 Button Attributes –value (string label on the button) –name (the name of the variable used to reference the button from JavaScript)

10 Button Demo Button

11 Check Box Attributes –checked (if this attribute is present, the box will be checked when the form loads) –name (the name of the variable used to reference the check box from JavaScript)

12 Check Box Demo Check Box US Citizen:

13 Radio Buttons Attributes –checked (if this attribute is present, the radio button will be selected when the form loads) –name (the name of the variable used to reference the radio button from JavaScript) NOTE: All radio buttons in the same group must be given the same name

14 Radio Buttons Demo Radio Buttons Freshman Sophomore Junior Senior

15 Text Area The value string goes here between the tags Attributes –cols (the width of the text area in characters) –rows (the height of the text area) –name (the name of the variable used to reference the text area from JavaScript)

16 Text Area Demo Text Area Type your address here.

17 Selection List Option 1 Option 2 …

18 Selection List Attributes –size (the number of options that should be visible) –name (the name of the variable used to reference the selection list from JavaScript) Attributes –selected (if this attribute is present, the option will be selected when the form loads)

19 Selection List Demo Selection List red green blue cyan magenta yellow

20 Event Handling Now that we have this nice form, there’s only one problem – it doesn’t do anything!

21 Event Handling We add behavior to HTML forms by adding “event handlers” to widgets An event handler is a little program that is run whenever a particular event occurs in a widget Examples of events: onclick for buttons, onchange for text boxes Example event handler: When this button is clicked, compute the tax and total for the order

22 Event Handling Each type of HTML form widget has “event handler attributes” The value of an event handler attribute is a JavaScript program that describes the actions to be performed when that particular event occurs in the widget

23 Event Handling Demo Text Box Title: Button

24 Event Handling We’ll learn a lot more about event handling in a future lecture, but first we need to learn the basics of JavaScript programming Once we’ve learned about JavaScript, we’ll be able to add interesting behavior to our HTML forms


Download ppt "HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back."

Similar presentations


Ads by Google