Expand my Community achievements bar.

Problem assigning multiple table cells into a variable.

Avatar

Level 1

I have a 24-row table with 8 cells. I want to assign 18 "Cell8" from various rows into a variable and 9 "Cell8" in a different named variable that will allow me to control what shows in the text based on a button click. Yes, I can, and have done this with single lines of code assigned on the click event of the button, but there has got to be a way to do this without 27 individual click event entries per button. I can create a variable, that works, assigning only one cell to the named variable. However, I am drawing a blank on the operator to add additional cell SOM to the list. This is the variable with the single-cell assigned that works "var groupThreea = Table1.Row1.Cell8;    this.resolveNode = (groupThreea).rawValue = "RDO"; ".. What am I missing to add another table.row.cell to the variable. I know it will be something simple that I should have known.

6 Replies

Avatar

Level 10

Hi, I think we might need a screenshot of the form hierarchy to understand what you are after. Does Row1 repeat or is each row named differently

Avatar

Level 1

Each row is consecutive. Row1 - Row2 - thru Row27. 8 cells in a row. lcimage.JPG

As you can see in the image I was merrily typing one-liners until they asked for some additional functionality in the form. I figured rather than typing all that and more, I should just set the different needed cells and their combinations into variables and just assign one (or several) function(s) for the variable.

Where I am drawing a blank is the "and".

I.E. var groupOnea = Table1.Row1.Cell8 (and) Table1.Row2.Cell8 (and) Tab.Row3.Cell8 (and)......;

I seem to have forgotten the operator and format for adding multiple items into the variable that aren't name or number values.

Avatar

Level 10

Hi,

You could try some code like;

var groupOneaArray = [];

var cell8Array = Table1.resolveNodes("#subform[*].Cell8")

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

groupOneaArray.push(cell8Array.item(i).rawValue);

}

groupOnea = groupOneaArray.join("")

Which will concatenate all the values of Cell8 in the table, I am assuming there aren't other rows without a Cell8.

Or to continue with your approach you can use the "+" operator on string to concatenate them

Avatar

Level 1

My current issue was addressing several random cell8 spots based on new button clicks. I was drawing a blank on concatenating multiple cells. The problem I am having is with the "+" operator. It seems to have no issues in creating str or var where I impart the value (var xxxxx = "this is great" + "that is great") However, setting a str or var to Table1.Row1.Cell8 + Table1.Row1.Cell8 gives me no errors but also no control of what the Cells display when added to the click event (.resolveNode). Inserting a comma to the str or var both seem to function normally as the last cell in the list shows the info on click (as if it reached the end of a loop function). Applying your code to this form and even modifying it for a test form ends in the same result. When multiple cells are addressed at once there are no errors in debug, but the desired displayed result is not there. I compiled a similar code string for a test table on a new form in case it was a bug in my current form due to the large amount of code elsewhere in the sheet. Same results. Having an HTML background has helped in this, but my understanding of variables and strings is they are value or info holders not object identifiers. I tried concat and let in this effort too. I seem to have hit a wall on telling 10 out of order cells to display something on click as a group without using single-line entries or the action builder over and over.

this.resolveNode("Table1.Row2.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row3.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row4.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row11.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row12.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row13.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row20.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row21.Cell8").rawValue = "RDO";

this.resolveNode("Table1.Row22.Cell8").rawValue = "RDO";

would be a lot prettier and easier to make future changes if it was

var thisArray= Table1.Row2.Cell8 thru Row4.Cell8 and Table1.Row11.Cell8 thru Row13.Cell8 and Table1.Row20.Cell8 thru Row22.Cell8;

this.resolveNode = (thisArray).rawValue = "RDO";

heh....

Avatar

Level 10

You could setup an array and loop though them, something like;

var thisArray = ["Table1.Row2.Cell8", "Table1.Row3.Cell8", "Table1.Row4.Cell8", "Table1.Row11.Cell8", "Table1.Row12.Cell8", "Table1.Row13.Cell8", "Table1.Row20.Cell8", "Table1.Row21.Cell8", "Table1.Row22.Cell8"]

thisArray.forEach(function(element) {

  xfa.resolveNode(element).rawValue = "RDO";

});

Which I guess is what you mean by your pseudo code?

In you description when you talk of using the "+" are you meaning you want to build up an array?  This would be something like;

var thisArray = []

thisArray.push("Table1.Row2.Cell8")

thisArray.push("Table1.Row3.Cell8")

or you could do it in one hit

var thisArray = []

thisArray.push("Table1.Row2.Cell8", "Table1.Row3.Cell8", "Table1.Row4.Cell8", "Table1.Row11.Cell8", "Table1.Row12.Cell8", "Table1.Row13.Cell8", "Table1.Row20.Cell8", "Table1.Row21.Cell8", "Table1.Row22.Cell8")

Avatar

Level 1

It seems I was using parenthesis instead of brackets in my array list.

Thank you BR001