These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Iterate over set of field ids using for loop

pavankumarreddyr
Registered: Dec 8 2008
Posts: 18
Answered

Hi Thomp,

I have a set of textfields with a button next to it, when i click on the button values will be shifted from one text field to other. Something like this:

myField__5.rawValue = myField__4.rawValue;
myField__4.rawValue = myField__3.rawValue;
myField__3.rawValue = myField__2.rawValue;
.
.

instead of doing like this i want to make it in a generic way by using a for loop, can you tell me how can i do that?

I tried like this:

for(var i =5 ; i>0 ; i--)
{
this.getField("myField__"+i).value = this.getField("myField__"+i-1).value;
}

but, its not working, is it the right way to do?

Thanks in Advance,
Pavan

R pavan kumar reddy

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Are you getting any errors?

What is the text of the error?

What script language are you using for this script in LiveCycle Designer?

Have you verified that the value of the field name you are trying to generate is being computed properly?

Have you tried to walk through the loop and see what is happening with each value of 'i'?

George Kaiser

pavankumarreddyr
Registered: Dec 8 2008
Posts: 18
Problem resolved:

This is the code for that:

for(var i=5; i >1 ; i--)
{
xfa.resolveNode("myField__"+i).rawValue = xfa.resolveNode("myField__"+(i-1)).rawValue;
}


-Pavan

R pavan kumar reddy