Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Get WF Variable Value in Javascript Dynamically

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Get WF Variable Value in Javascript Dynamically
 Login/Join
 
Platinum Member
posted
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.

-SET &WFVARCNT = 2;
-SET &WFVAR1 = "X1";
-SET &WFVAR2 = "X2";

-HTMLFORM BEGIN

function test() {

WFVarValue = new Array();

// 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
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
Expert
posted Hide Post
Sean, welcome to FocalPoint.


What you want to do is not pretty! Here is a solution.

-SET &ECHO=ALL;

-SET &WFVARCNT = 2;
-SET &WFVAR1 = 'X1';
-SET &WFVAR2 = 'X2';

-HTMLFORM BEGIN


<script type="text/javascript">

// 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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
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!

Thanks again,
Sean
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
Expert
posted Hide Post
Nice to see a happy customer!
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Get WF Variable Value in Javascript Dynamically

Copyright © 1996-2020 Information Builders