Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 HTML forms (cont.)

Similar presentations


Presentation on theme: "1 HTML forms (cont.)"— Presentation transcript:

1 1 HTML forms (cont.) http://jjcweb.jjay.cuny.edu/ssengupta/

2 2 Creating form buttons  Form buttons can be clicked to o run programs o submit forms o reset the form to its original state

3 3 Creating push buttons  syntax for creating a push button o text is the text that appears on the button  push buttons perform no actions by themselves  need a script to associate an action with a push button

4 4 Creating submit/reset buttons  a submit button is a button that submits the form to a CGI script for processing  a reset button erases users ’ input and resets form to its original (default) values  the syntax for creating these two buttons is: o value attribute defines the text that appears on the button

5 5 Using name and value attributes  use name and value attributes when a form contains multiple buttons

6 6 Creating buttons using the tag  tag does not allow the Web page designer to control the appearance of a button  tag enables artistic control over the appearance of form buttons  The syntax of the tag is: button text and HTML tags o name attribute specifies the name of the button o value attribute sends to a CGI script o type attribute specifies the button type (submit, reset, or button)

7 7 Example the button type is a simple push button contents of the button button image The figure shows how to create a button that contains formatted text and an inline image. The default value for the type attribute is “button”. Within the tags you can place whatever HTML tags you wish to format the button’s appearance. This includes inline images. Go to the Home Page

8 8 Different button styles and actions Back Forward Google Reload Close

9 9 Creating file buttons  a file button is used to select files  contents of the file are not displayed--only the file ’ s location is  syntax for creating a file button here, type attribute’s value is “file”

10 10 Using a file button, example 1. User clicks the Browse button 2. Selects a file from the Choose File dialog box 3. The filename and location are automatically placed in the text box The figure shows an example of using the file button to return the location of a file named “report.doc.”

11 11 Working with form attributes  attributes to the tag o specify where to send the form data o specify how to send  syntax o action specifies the filename and location of the CGI script that process the form o method specifies how your Web browser sends data to the CGI script o enctype specifies the format of the data stored in the form ’ s field

12 12 The method attribute  two possible values for the method attribute o get or post  get method (default value for method attribute) o packages the form data by appending it to the end of the URL specified in the action attribute o some Web servers limit the amount of data sent via get method and will cut off valuable information  post method o sends form data in a separate data stream, allowing the Web server to receive the data through what is called “ standard input ” o is preferred for sending data to a Web server o Web servers do not limit the amount of data sent via post method

13 13 The enctype attribute  defines the technique used to encrypt form data  default enctype value is “ application/x-www-form- urlencoded. ”  another enctype value that is often used is “ multipart/form-data, ”  The most basic way of encoding data is to use “ text/plain, ” which encodes the data as simple text.

14 14 Specifying where and how to send form data This following example shows the CGI script that processes the form is located at the URL http://www.langear.com/cgi/mailer (a fictional address) and uses the “post” method. LanGear Registration Form <form name=“reg” action=“http://www.langear.com/cgi/mailer” method=“post”>


Download ppt "1 HTML forms (cont.)"

Similar presentations


Ads by Google