How can I dynamically update the contents of a Web drop down list?
|Date:||29 March 2004|
|Product/Release:||LANSA for the Web|
|Abstract:||How can I dynamically update a drop-down list from an AS/400 file, which changes frequently, without having to recompile or manually change the HTML in a Web component every time the file changes?|
|Submitted By:||LANSA Services|
We want to build a drop-down list. The data set (AS/400 file) is small, but dynamic. The data could change frequently, and we do not want to have to recompile or manually change HTML in a Web component every time this happens. Ideally, we would like to build the list from the file each time the function is executed. Do you have any suggestions for this type of approach?
Is the iSeries file on which the drop-down is to be based maintained by LANSA functions (i.e. leveraging the OAMs)?
If so, then you could add a LANSA trigger to the file to regenerate the Web component (drop-down) from the file AFTINS AFTDEL AFTUPD as appropriate. See "Calling W3@P2600 from a trigger function" for more information.
If not, then you can define a browselist in your function (the function that displays the page with the drop-down). Use standard SELECT command techniques to populate the browselist from the AS/400 file. Below your main DISPLAY command, create a second DISPLAY command with the browselist in it.
The browselist should be defined with all fields *HIDDEN except for one, which has *NOID. A component should be created to match the name of this field. Then, in the HTML for this component, you can include the HTML "OPTION" tag so that each row in the browselist is really being "shown" as a value in the dropdown.
You'll also need to ensure that the browselist is merged into your page, so that it is displayed on the first DISPLAY command.