Expand my Community achievements bar.

SOLVED

Populating a Table

Avatar

Level 3

How do you populate certain table cells if and when a text box previously within the form has been filled out.  What I'm trying to do is if the user files out say their name and address, the name and address data would automatically transfer to the table and fill in the cells.  I have been trying to find information on this and I'm having no luck.  Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

In general, this can be done in many ways.

I have an example for you to start.

It uses FormCalc as it is easier to reference form fields in thie language than in JavaScript.

So the code is quite slim.

You will need to design a dynamic table with repeatable rows to use this code!

var nName = Name.rawValue

var nAddress = Address.rawValue

var nRow = Table.Row.instanceManager.count -1

if (Table.Row[nRow].Cell1.rawValue ne null) then

     Table.Row.instanceManager.addInstance(1)

     nRow = nRow + 1

endif

Table.Row[nRow].Cell1.rawValue = nName

Table.Row[nRow].Cell2.rawValue = nAddress

https://acrobat.com/#d=dP3iWPzoMbEf8P4v-6m1Ug

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

In general, this can be done in many ways.

I have an example for you to start.

It uses FormCalc as it is easier to reference form fields in thie language than in JavaScript.

So the code is quite slim.

You will need to design a dynamic table with repeatable rows to use this code!

var nName = Name.rawValue

var nAddress = Address.rawValue

var nRow = Table.Row.instanceManager.count -1

if (Table.Row[nRow].Cell1.rawValue ne null) then

     Table.Row.instanceManager.addInstance(1)

     nRow = nRow + 1

endif

Table.Row[nRow].Cell1.rawValue = nName

Table.Row[nRow].Cell2.rawValue = nAddress

https://acrobat.com/#d=dP3iWPzoMbEf8P4v-6m1Ug

Avatar

Level 3

This is definitely what I'm looking for and I got it to work...the only issue I have is that the 1st row doesn't populate it goes to the second row automatically.  Is this right, I used the script on the button and I have it on the Click option and I'm using FormCalc.  Sorry I'm working on an intranet for this and I can't view the example you sent me using LiveCycle.  *Thanks for you help*

Avatar

Level 10

Its hard to tell what's causing this problem with your form.

My sample has a dynamic table that begins with one row.

The script counts all present the rows and uses this counter to address the latest instance of the rows.

It also checks if the first field in that latest row is empty.

If so, this row will be populated else a new row is added and populated then.

Avatar

Level 3

I'm not sure what's going on either but I played around with this part of the script and I got it to work but then something else would not work right.  Anyway I think I got it to where I'm happy with the results.

Thanks for your help.

if (Table.Row[nRow].Cell1.rawValue ne null) then

     Table.Row.instanceManager.addInstance(1)

     nRow = nRow + 1