Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

changing the value for Text inside a column of a dynamic table

Avatar

Level 4

Hi Folks,

           I get a great help from this forum and i follow very frequently. This time i have a question regarding Tables, how to manipulate fields in a table using JavaScript. The requirement is as follows, I have a Table (100rows x 3columns) and few of them are hidden from layout. The first column contains the text values such as sequential numbers, (the first column is visual index, 1, 2, ,3 ... 100). Now, i am trying to write a script which, replaces or overrides the first column values in text boxes to spaces. Can you guys help me out if making a script? or provide me some resources where i can manipulate table fields using JavaScript?

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

It looks like the table is static and will always have three rows at runtime. In other words the user cannot add more rows. If this correct?

You don't need to resolve the nodes in this case, because you are referencing specific rows and fields.

Becuase the script is in the checkbox, which is in the same container as the table, the following would clear the contents of the fields in the second column:

Table1.Row1[1].TextField3.rawValue = null; 

Your script is accessing an object in the second row called Cell1. This appears to be a Text object and does not have a .rawValue property. If you want to change the value at runtime, you would need to change this to a TextField object.

In addition it looks like there isn't an object in the second row (Row1[1]) called "Cell1". It looks like the first object is unnamed. This will also cause the script to fail. When debugging it is useful to use the JavaScript Console to see errors (Control+J) when previewing the form or in Acrobat.

Does that help?

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

I am not sure I understand what you are trying to achieve: replacing the values with spaces. Can you provide more information or the form?

If you want to loop through a table, you will need to set up a for loop. See the SOM expression example, in particular pages 10 and 11. http://assure.ly/kUP02y

Some examples that might help:

Building tables: http://assure.ly/gk8Q7a

Looping through rows: http://assure.ly/haaOfc

Hope that helps,

Niall

Avatar

Level 4

image.jpg

Hi Niall,

            The Samples that you have provided were helpful in understanding the structure of the Table, and i thank you for that Niall. But, i coudn't acheive what i have thought to implement. The image attached has little working on the table and the script, can you please correct me.

Column 1: ID, has all text values where as in

Column 2: Header, has all "textfield" values, i could acheive hidding this columns values

The following is the script when error,"GeneralError:Operation Failed"

try{
xfa.resolveNode("form1.PageOne.Table1.Row1[1]").Cell1.rawValue = "";
}catch(e2){ app.alert("Second Loop: "+e2); }

please help me out.

thank you, in advance.

Avatar

Correct answer by
Level 10

Hi,

It looks like the table is static and will always have three rows at runtime. In other words the user cannot add more rows. If this correct?

You don't need to resolve the nodes in this case, because you are referencing specific rows and fields.

Becuase the script is in the checkbox, which is in the same container as the table, the following would clear the contents of the fields in the second column:

Table1.Row1[1].TextField3.rawValue = null; 

Your script is accessing an object in the second row called Cell1. This appears to be a Text object and does not have a .rawValue property. If you want to change the value at runtime, you would need to change this to a TextField object.

In addition it looks like there isn't an object in the second row (Row1[1]) called "Cell1". It looks like the first object is unnamed. This will also cause the script to fail. When debugging it is useful to use the JavaScript Console to see errors (Control+J) when previewing the form or in Acrobat.

Does that help?

Niall

Avatar

Level 4

Yes, indeed your information helped me a loot on tables, Thank you Niall. I was trying to access the value of a non-object parameter, got confirmation from you, and which is not possible and instead i have to use regular numeric or textfield objects to access the value.

Thank You