Obtain All Values from Multivalue Input Fields in WebBroker Applications (cont'd)


WebBroker Technology in Action
Step one is to create a Web server application that uses the WebBroker technology. Do a File | New and select the Web Server Application icon from the Object Repository. In the dialog that follows, pick a simple CGI standalone executable as your Web server application. In order to use meaningful names, save your project as WebProj1 and your Web module (unit1) as WebMod.

Once the code for your Web server project has been generated and saved, click in the left pane of the designer and add one new Web action—you need only one to illustrate this month's problem and solution. Create a single WebItemAction, set its Default property to True, and get ready to write code for its OnAction event handler.

HTML Input Forms
Web server applications usually produce dynamic HTML, but they can respond to user input as well. To make these apps responsive to user input, you need an HTML form that contains so-called input fields. The choices for input fields are limited. You can have editboxes, memo fields (a multi-line editbox), radiobuttons, checkboxes, a listbox or comboboxes, and buttons. Each of these input fields except for the listbox accepts a single value, like the text a user enters. The listbox can be multi-valued, meaning you can select more than one item in it.

Listing 1 below shows an HTML form that contains an editbox, multivalued listbox, and two buttons (Note that METHOD=POST could also have been METHOD=GET):

<HTML>
<BODY>
<FORM ACTION="http://192.168.92.201/cgi-bin/WebProj1.exe" 
METHOD="POST"> Name: <INPUT TYPE="edit" NAME="Name" SIZE="16"> <P> Delphi Version: <SELECT NAME="Delphi" MULTIPLE> <OPTION VALUE="D1"> Delphi 1 <OPTION VALUE="D2"> Delphi 2 <OPTION VALUE="D3"> Delphi 3 <OPTION VALUE="D4"> Delphi 4 <OPTION VALUE="D5"> Delphi 5 <OPTION VALUE="D6"> Delphi 6 </SELECT> <P> <INPUT TYPE="RESET" VALUE="Reset Query"> <INPUT TYPE="SUBMIT" VALUE="Submit"> </FORM> </BODY> </HTML> Listing 1. HTML Input Form
Figure 1 shows the HTML form as seen inside Netscape Communicator 4.7. A similar form will be obtained inside Microsoft Internet Explorer.

FIGURE 1: Our HTML form as seen inside Netscape Communicator 4.7.




Previous: Introduction
 
Next: Single-Value Input Fields


Introduction Single-Value Input Fields
WebBroker Technology in Action Collecting Values from All Input Fields


Return to Get Help with Delphi Page

Return to Main Get Help Page
 
With Delphi's WebBroker Technology, you can produce Web server applications and obtain user input with HTML forms. However, sometimes you'll need to obtain the data from multivalue input fields like a multi-select listbox, in which case the Values property returns only the first value and not the rest.




Using a small code routine, extract all values from a multivalue input field in WebBroker applications.


Find Out More
Dr. Bob on Delphi Web Modules

The WebBroker: CGI and ISAPI chapter from Charlie Calver's Delphi 4 Unleashed

TALK BACK
This month's 10-Minute Solution is necessary because the current implementation of Value returns only the first value and a string for the name (and not an index) must be specified to find values. What improvements would you make to Delphi to make this solution obsolete? Let us know in the database development discussion groups!
 





Sponsored Links