To run a fex where user can select 'ALL' to see a report of cars in all countries, or select a specific country to appear in a report.
-SET &ECHO=ALL;
-*
-? &
-RUN
TABLE FILE CAR
PRINT
CAR
BY COUNTRY
WHERE COUNTRY EQ '&COUNTRY';
END
I am having a problem getting the launch page to reload with the country I just selected to appear in the 1st position in the country dropdown. For example, if I chose 'FRANCE' on the initial launch page, I would like the launch page to reload with this…
Here is one approach that relies on -INCLUDE of a focexec before the beginning of the HTML (-HTMLFORM BEGIN) in your launch page. The focexec would look something like this.
-DEFAULTS &COUNTRY = ' '
-*
DEFINE FILE CAR
CTRY_OPTION/A60 = IF (COUNTRY EQ '&COUNTRY')
THEN ('<option selected value="' | COUNTRY || '">' || COUNTRY || '</option>')
ELSE ('<option value="' | COUNTRY || '">' || COUNTRY || '</option>');
END
-*
TABLE FILE CAR
SUM CTRY_OPTION
BY COUNTRY NOPRINT
ON TABLE SAVE AS CTRYHTML
END
The first time you launch your form, &COUNTRY will default to blank and the SELECT will default to 'All' at the top of the list. If the user selects a country, variable &COUNTRY will be populated with that value and subsequent launches of the form will select that country as the default.
The SELECT in your HTML would change to incorporate the SAVE file created by the focexec:
-MRNOEDIT -INCLUDE <focexec name>
-HTMLFORM BEGIN
.
.
<SELECT name="Country" size="1">
<OPTION VALUE="$">All</OPTION>
!IBI.FIL.CTRYHTML;
</SELECT>
.
.
-HTMLFORM END
I suggest replacing the VALUE for "All" from "ALL" to "$" so your WHERE clause becomes
WHERE COUNTRY EQ '$';
instead of
WHERE COUNTRY EQ 'ALL';
If you prefer to use a static SELECT statement, then you might try something like this.
-DEFAULTS &COUNTRY = ' '
-DEFAULTS &SEL_ENGLAND = ' ', &SEL_FRANCE = ' ', &SEL_ITALY = ' '
-DEFAULTS &SEL_JAPAN = ' ', &SEL_GERMANY = ' '
-*
-SET &SEL_ENGLAND = IF '&COUNTRY' EQ 'ENGLAND' THEN 'SELECTED' ELSE ' ';
-SET &SEL_FRANCE = IF '&COUNTRY' EQ 'FRANCE' THEN 'SELECTED' ELSE ' ';
-SET &SEL_ITALY = IF '&COUNTRY' EQ 'ITALY' THEN 'SELECTED' ELSE ' ';
-SET &SEL_JAPAN = IF '&COUNTRY' EQ 'JAPAN' THEN 'SELECTED' ELSE ' ';
-SET &SEL_GERMANY = IF '&COUNTRY' EQ 'W GERMANY' THEN 'SELECTED' ELSE ' ';
-*
-HTMLFORM BEGIN
.
.
<SELECT name="Country" size="1">
<OPTION VALUE="ALL">All</OPTION>
<OPTION &SEL_ENGLAND VALUE="ENGLAND">England</OPTION>
<OPTION &SEL_FRANCE VALUE="FRANCE">France</OPTION>
<OPTION &SEL_ITALY VALUE="ITALY">Italy</OPTION>
<OPTION &SEL_JAPAN VALUE="JAPAN">Japan</OPTION>
<OPTION &SEL_GERMANY VALUE="W GERMANY">Germany</OPTION>
</SELECT>
.
.
-HTMLFORM END