.
 News & Views
  The online information source for iSeries and mrc-Productivity Series users
.  September 2002  
Volume 2, Issue 9  
.
. . . . . . . . .

Tech Corner

Populate a drop-down list from a file

by Brian Crowley
Drop-down list article Application builders are always looking for methods to improve the interface for their end-users. The mrc-Productivity Series continues to advance methods for doing so. Web/CGI maintenance templates now include the ability to populate a drop-down list from a file. The application builder uses a powerful external object technique to create the HTML text on the fly.

How can I do it?

In short, you can populate a drop-down list from a file by copying a provided external object and defining it to your application. Follow the example of ODROPSTATE, which is an RPG program that creates a drop-down list of state codes and their descriptions, based on the records in a database file.

Like many other external objects, it is available as a free download from our object repository in the customers-only area: http://www.mrc-productivity.com/members/software/extobj.html

The supplied example is specific to the physical file it uses. You will need to tailor the program to match your file information. Specifically, these things need to be changed:

1. File name
2. File library
3. Value field name (value that goes into the file field)
4. Description field name (text that is displayed in the drop-down list)
5. Maintenance application form field name (such as K005)

Compile your object, define it to mrc, and use the object in the applications which need it, specifying that the object should be called at template location *DROPDOWN. If that location does not exist, please update your templates with the latest version of the mrc-Productivity Series. After compiling the mrc-generated application, you would need to paint a single line within the HTML skeleton to make the display piece function properly with the new drop-down you've created. The following code shows the required change:

Original HTML source:
<TD><INPUT size=002 maxlength=002 type="text" name="K013" value="@K013">

Modified HTML source:
<TD>@K013

Then your application is ready to run from your browser.

Live on the Web

See an application using this technique live on the Web: http://www.crazybikes.com/dealersarea.html. Please log on with a sample dealer/customer profile provided, choose "Manage My Account" and then "Update Account Info". The states listed in the drop-down input are coming from a live database file.

Options

The source code of the external object contains further details about other options you may want. For example, you may want the first line of the drop-down list to read, "Please select a state." Further, you might want to display more than just one field as the text in the drop-down list. For a hotel reservations application, you might want to display more than just the hotel name, like this: "Hyatt Chicago Downtown : $225 nightly : 12 Rooms Available".

Concatenating the fields together into one string is easily done inside the RPG external object. Another powerful feature this technique gives is the ability to select records from the file on the fly. You may want to display only records that have rooms available or some other logic based on the user.

Further, if you wish to create a radio button input field, this technique would also work and require only some tweaking of the HTML code within the external object.

If you have other ideas for improving the interface of applications created with the mrc-Productivity Series, please let us know!



Take Our Poll

What does your application backlog look like?

6+ months
3-6 months
1-3 months
>1 month
No backlog
Don't know

View Results
View Poll Archive

.
.
.
.
. Quick Links...

Visit mrc's Web site

See a live demo

Get more information

View Latest Newsletter

Last Month's Newsletter

.
.
.
.
. Contact mrc...

U.S. Offices
mrc@mrc-productivity.com

voice: 630-916-0662

www.mrc-productivity.com



U.K. Offices
michaels, ross & cole (UK) ltd

voice (UK): +44 (0)20 8282 1600

mail@mrcuk.com


.
 mrc publishes this newsletter on a monthly basis. Subscription is free of charge. Please send any questions or comments about this newsletter to news@mrc-productivity.com. This newsletter is edited by Heather Gately.

To unsubscribe, please just reply to this e-mail with Unsubscribe in the subject line.
View our privacy promise.

.