Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How Do I iterate through a text array?

Avatar

Former Community Member
I have a group of text boxes and would like to iterate through them assign value change access I have three text boxes MytxtBox[0], MytxtBox[1], MytxtBox[2]

Example in JavaScript



var row;

for (row=0;row<3;row++)

{

xfa.host.messageBox(xfa.form.MyDocument.MyForm.MytxtBox[0]);

xfa.host.messageBox(xfa.form.MyDocument.MyForm.MytxtBox[0].access);

}



I get a script error show that xfa.form.MyDocument.MyForm.MytxtBox[0] has no properties

I can get the values in FormCalc however I cant run a form loop

Does anyone have any ideas how to work the For loop in FormCalc or iterate in JavaScript through the textbox array?
1 Reply

Avatar

Former Community Member
In JavaScript you'd do something like:



var nodeList = xfa.resolveNodes("MytxtBox[*]");

for (i = 0; i < nodeList.length; i++) {

xfa.host.messageBox(nodeList.item(i).access);

}



I haven't tried the script, so there may be some syntax errors, but that's how you do it.



FormCalc would be something like:



for i = 0 upto 2 do

$host.messageBox(MytxtBox[i].access)

endfor



Chris

Adobe Enterprise Developer Support