I am switching from cgi-bin to WFServlet, and a section of code that contains blocks of -HTMLFORM BEGIN and -HTMLFORM END intermingled with Dialogue Manager is now failing. So I want to convert the code to Javascript in one -HTMLFORM block. But I need to access the values of dynamically generated WebFocus variable names in Javascript, which I can't figure out how to do. A small sample of code illustrating what I am trying to accomplish is included below. Any help would be appreciated.
// dynamically build WF variable name, then // store value of variable for (idx=1; idx<=!IBI.AMP.WFVARCNT;; idx++) { WFVarName = '!IBI.AMP.WFVAR' + idx + ';'; // -> need WFVarValue[idx] = value of WFVarName } }
-HTMLFORM END
November 04, 2005, 03:57 PM
Francis Mariani
Sean, welcome to FocalPoint.
What you want to do is not pretty! Here is a solution.
// Declare Array WFVarValue = new Array(); /* -HTMLFORM END
-REPEAT REP_END1 FOR &COUNTER FROM 1 TO &WFVARCNT
-SET &VAR = &WFVAR.&COUNTER;
-HTMLFORM BEGIN */ WFVarValue[!IBI.AMP.COUNTER;] = '!IBI.AMP.VAR;'; /* -HTMLFORM END
-REP_END1
-HTMLFORM BEGIN */ function test() {
for (idx=1; idx<=!IBI.AMP.WFVARCNT;; idx++) { alert(WFVarValue[idx]); } }
-HTMLFORM END
The Javascript comment tags (/* */) are there to disable the HTML comments that WebFOCUS puts in at every HTMLFORM BEGIN and END. To see what I mean, view source after running this fex.
Francis.This message has been edited. Last edited by: <Maryellen>,
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
November 04, 2005, 04:57 PM
smiths
Francis,
Thanks for the welcome, and even more thanks for this solution! You are awesome!! Adding the /* and */ worked like a charm!! We're going to have to get you bumped up to 5 stars!