Expand my Community achievements bar.

SOLVED

Need Help Populating single textfield with Dynamic Table data

Avatar

Level 2

Hello

I'm trying to fill a text field with data from a dynamic table. So I know how many item are in the table with the instancemanager.count function. I need help getting the data from the dynamic table and inserting it into one text field followed by comma.

Example:

               Dynamic table :     row[1]: DATA_01

                                            row[2]: DATA_02

                                            row[3]: DATA_03

                                            ...

I would like the textbox to automatically populate with the data in this format: DATA_01, DATA_02, DATA_03... and continue if there are more data.

I started with the code below but it doesn't do the job.                               

var Count = form1.page2.DATA_history.instanceManager.count;

var temp;

for (var i = 0; i<Count; i++)

{

    temp = xfa.resolveNode("form1.page2.PO_history[" + i + "]").DATA.rawValue;      // this seem to get the last row entry only.

    this.rawValue = this.rawValue + temp;                                                                 

}

I hope I was clear, but if anyone need clarification please ask. Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Try the following:

var Count = form1.page2.DATA_history.instanceManager.count;

var temp = "";

for (var i = 0; i<Count; i++)

{

    temp = temp + xfa.resolveNode("form1.page2.PO_history[" + i + "]").DATA.rawValue + ", ";                                             

}

this.rawValue = temp;

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi,

Try the following:

var Count = form1.page2.DATA_history.instanceManager.count;

var temp = "";

for (var i = 0; i<Count; i++)

{

    temp = temp + xfa.resolveNode("form1.page2.PO_history[" + i + "]").DATA.rawValue + ", ";                                             

}

this.rawValue = temp;

Avatar

Former Community Member

In my table, I have

Row1[0]

Row1[1]

Row1[2]

...

which is the way LiveCycle automatically names rows (I haven't renamed them).

Each row has several cells. I renamed the first column cells:

data_00

data_01

data_02

...

Now, considering that instance index is 0-based as said here http://forums.adobe.com/thread/607657

var Count = form1.pag2.Table2.instanceManager.count;

var temp = "";

for (var i = 0; i<Count+1; i++)

{

     temp = temp + xfa.resolveNode("#subform.Table2.Row1["+i+"].data_0"+i).rawValue + ", ";                                            

}

TextField3.rawValue = temp.substring(0, temp.length - 2);

The last row substring method just removes the trailing ", " from the resulting string.

I tested it and it works: it makes a string out of all first column cells' values and put it into TextField3.

Hope it helps.

Avatar

Level 2

Thank you very much your code was exactly what I needed. Also thanks mrfale67 for the link and I didnt knew that about the 0 index. I tryed the code and at first didn't work but I realize it  was my trigger event that made it not activate so I switch to calcaluated but it showed null value when empty. I rather the value be blank when empty but I figure it from here guys thanks for everything.