Focal Point
[SOLVED] Passing checkbox value from fex to the same fex

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/662102432

September 09, 2009, 08:07 AM
MrM
[SOLVED] Passing checkbox value from fex to the same fex
Is it possible to use checkboxes in the header of a fex application.
This is needed to make a print mechanism so we can indicate which columns will and will not be printed in PDF. We now use a script, and by clicking on the right mouse a box appears to select 'show in EXCEL or PDF' and then the same fex will be called.

This message has been edited. Last edited by: Kerry,
September 09, 2009, 09:49 AM
Francis Mariani
If you mean is it possible to use checkboxes in the header of an HTML report that are subsequently passed back to the same program to rerun the report in PDF format, then yes, but you most likely will not be able to do that with the GUI tools in Dev Studio or MRE. You will manually have to add code to add check-box html objects to the column titles of the report (HTML only) and then add JavaScript to collect the check-boxes and add them to the focexec call. It sounds like an interesting challenge for you, MrM.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 09, 2009, 10:17 AM
j.gross
It may be easiest to create hidden parameter controls (via the GUI) in the static html, for each of the checkable columns. Then your onsubmit code need only copy values between controls, and IBI will take it from there.


- Jack Gross
WF through 8.1.05
September 09, 2009, 01:43 PM
Darin Lee
Or easier yet, if you're just putting them in the heading, add a line that says something like "Output Types" and then add a multidrill to that heading line which passes all the necessary parms with an output type as an additional parm. That still gives you the pop-up box type functionality, but handles everything as a url (drilldown) so no additional javascript or report coding is necessary and this can all be done in Dev Studio / MRE.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
September 10, 2009, 05:16 AM
MrM
First thanks all for your reply.

Would it be possible to show checkboxes by using code like below.
The code below don't show me the right result.


-* File checkcar.fex
-SET &ECHO=ALL;

DEFINE FILE CAR
COL001/A1='';
CHKBOX001/A50='';
END

TABLE FILE CAR
PRINT
CAR.COUNTRY
COL001 AS CHKBOX001
CAR.CAR
CAR.MODEL
CAR.BODYTYPE
HEADING
""
FOOTING
""
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='ARIAL',
SIZE=9,
$
ENDSTYLE
END
September 10, 2009, 07:11 AM
<JG>
I would tend to look at something like this so that the check box is associated with the column title

 
-DEFAULTH &FMT    = 'HTML'
-DEFAULTH &COUNTRY ='COUNTRY'
-DEFAULTH &CAR     ='CAR'
-DEFAULTH &MODEL   ='MODEL'
-DEFAULTH &BODYTYPE='BODYTYPE'

-SET &ASCOUNTRY  = IF '&FMT.EVAL' EQ 'HTML' THEN 'AS '|''''||'Country  <INPUT TYPE=CHECKBOX ID="COUNTRY"  NAME="COUNTRY"  VALUE="COUNTRY">'|'''' ELSE 'AS '|''''||'Country' ||'''';
-SET &ASCAR      = IF '&FMT.EVAL' EQ 'HTML' THEN 'AS '|''''||'Car      <INPUT TYPE=CHECKBOX ID="CAR"      NAME="CAR"      VALUE="CAR">'||'''' ELSE  'AS '|''''||'Car' ||'''';
-SET &ASMODEL    = IF '&FMT.EVAL' EQ 'HTML' THEN 'AS '|''''||'Model    <INPUT TYPE=CHECKBOX ID="MODEL"    NAME="MODEL"    VALUE="MODEL">'||'''' ELSE  'AS '|''''||'Model' ||'''';
-SET &ASBODYTYPE = IF '&FMT.EVAL' EQ 'HTML' THEN 'AS '|''''||'Bodytype <INPUT TYPE=CHECKBOX ID="BODYTYPE" NAME="BODYTYPE" VALUE="BODYTYPE">'|'''' ELSE  'AS '|''''||'Bodytype' ||'''';

TABLE FILE CAR
PRINT
&COUNTRY   &ASCOUNTRY
&CAR       &ASCAR
&MODEL     &ASMODEL
&BODYTYPE  &ASBODYTYPE
HEADING
"Export"
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT &FMT
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
-IF '&FMT.EVAL' NE 'HTML' GOTO NONHTM;
TYPE=HEADING,DRILLMENUITEM='PDF',FOCEXEC=test02(FMT='PDF'),
             DRILLMENUITEM='Excel',FOCEXEC=test02(FMT='EXL2K'),$ 
-NONHTM
ENDSTYLE
END
-RUN
 

September 10, 2009, 11:10 AM
Francis Mariani
JG,

In your example, the check-box values are not passed back to the program, so the program does not know which columns were selected by the user.

Some JavaScript added to your code and a few tweaks solves the problem:

-SET &ECHO=ALL;

-DEFAULTH &FMT    = 'HTML'
-DEFAULTH &COUNTRY =''
-DEFAULTH &CAR     =''
-DEFAULTH &MODEL   =''
-DEFAULTH &BODYTYPE=''

-SET &HEAD1 = IF &FMT EQ 'HTML' THEN 'Export' ELSE '';

-SET &PCOUNTRY  = IF &COUNTRY  EQ 'N' THEN '-*' ELSE 'COUNTRY ';
-SET &PCAR      = IF &CAR      EQ 'N' THEN '-*' ELSE 'CAR     ';
-SET &PMODEL    = IF &MODEL    EQ 'N' THEN '-*' ELSE 'MODEL   ';
-SET &PBODYTYPE = IF &BODYTYPE EQ 'N' THEN '-*' ELSE 'BODYTYPE';

-SET &ASCOUNTRY  = IF &FMT EQ 'HTML' THEN 'AS ''<input type=checkbox id="COUNTRY" > Country ''' ELSE 'AS ''Country''';
-SET &ASCAR      = IF &FMT EQ 'HTML' THEN 'AS ''<input type=checkbox id="CAR"     > Car     ''' ELSE 'AS ''Car''';
-SET &ASMODEL    = IF &FMT EQ 'HTML' THEN 'AS ''<input type=checkbox id="MODEL"   > Model   ''' ELSE 'AS ''Model''';
-SET &ASBODYTYPE = IF &FMT EQ 'HTML' THEN 'AS ''<input type=checkbox id="BODYTYPE"> Bodytype''' ELSE 'AS ''Bodytype''';

TABLE FILE CAR
PRINT
COUNTRY NOPRINT
&PCOUNTRY.EVAL   &ASCOUNTRY
&PCAR.EVAL       &ASCAR
&PMODEL.EVAL     &ASMODEL
&PBODYTYPE.EVAL  &ASBODYTYPE

HEADING
"Customized Car Report"
"&HEAD1"

ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT &FMT
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
UNITS=IN,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$

-IF &FMT NE 'HTML' GOTO NONHTM;

TYPE=HEADING, LINE=2,
DRILLMENUITEM='PDF',   JAVASCRIPT = RerunReport('PDF'),
DRILLMENUITEM='Excel', JAVASCRIPT = RerunReport('EXL2K'),
$
-NONHTM
ENDSTYLE
END
-RUN

-NONHTM
ENDSTYLE
END
-RUN

-HTMLFORM BEGIN
<script language='javascript'>
function RerunReport(FMT)
{
focexurl1 = document.location +
'&|FMT=' + FMT +
'&|COUNTRY='  + GetCheckBoxValue(document.getElementById('COUNTRY')) +
'&|CAR='      + GetCheckBoxValue(document.getElementById('CAR'))     +
'&|MODEL='    + GetCheckBoxValue(document.getElementById('MODEL'))   +
'&|BODYTYPE=' + GetCheckBoxValue(document.getElementById('BODYTYPE'));
;

window.open(focexurl1,'win1');
}

// Return Y or N depending on the checked status of a check box
function GetCheckBoxValue(CheckBox)
{
if (CheckBox.checked == true) x = 'Y'; else x = 'N';

return(x);
}

</script>
-HTMLFORM END

I realize this is antiquated but it does work.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 11, 2009, 01:57 AM
<JG>
Francis,

Thanks for adding the finishing touches,
I know that what I posted did not return the values it was meant only to illustrate
a method of actually displaying the check boxes in reply to the sample code posted by
MrM.

And bye the way Francis there is definitely nothing wrong with some the older ways
of doing things.
To be honest they are generally much more reliable and user friendly than of some
of the newer rubbish that is around now.
September 11, 2009, 02:30 AM
MrM
thanks all.

I will use the examples.
September 11, 2009, 02:57 AM
<JG>
MrM

To get Francis's modified code to work you need to change

focexurl1 = document.location +

to

focexurl1 = document.location + '?IBIF_ex=test02' +