Expand my Community achievements bar.

Filling a Table from text boxes

Avatar

Level 3

This is what I am starting with

Table1.Row1.Cell2.rawValue = TextField3.rawValue;
                  TextField3.rawValue = "";
                  Table1.Row1.Cell3.rawValue = TextField2.rawValue;
                  Table1.Row1.instanceManager.addInstance(1);

This is on my button click. The table gets filled from the Text field.

However i need to move the Row in the table to the next row.

Can i do this with some kind of variable like

var n;

n = "1";

Table1.Row(n).Cell2.rawValue = TextField3.rawValue;
TextField3.rawValue = "";
Table1.Row(n).Cell3.rawValue = TextField2.rawValue;
Table1.Row1.instanceManager.addInstance(1);

n + 1

My syntax is probably way off but is there a way to do something like this??

3 Replies

Avatar

Former Community Member

I think this is what you are looking for.

This script is attached to the click event on the  'Add Result' button of the attached PDF. It takes the values from the columns in the last row of the table, creates a new row, populates the columns in the new row with the column values from the former last row, and resets the second last row.

var lastRow = form1.page1.subform1.table._row.count;
var currentRow = lastRow - 1;

var wins_ = table.resolveNode("row[" + currentRow + "].wins");
var draws_ = table.resolveNode("row[" + currentRow + "].draws");
var losses_ = table.resolveNode("row[" + currentRow + "].losses");

form1.page1.subform1.table.row.instanceManager.addInstance(1);

table.resolveNode("row[" + lastRow + "].wins").rawValue = wins_.rawValue;
table.resolveNode("row[" + lastRow + "].draws").rawValue = draws_.rawValue;
table.resolveNode("row[" + lastRow + "].losses").rawValue = losses_.rawValue;

table.resolveNode("row[" + currentRow + "].wins").rawValue = "";
table.resolveNode("row[" + currentRow + "].draws").rawValue = "";
table.resolveNode("row[" + currentRow + "].losses").rawValue = "";

Steve

Avatar

Level 3

That seems like it should work. However, i must be missing something. I have changed all the names to match up correctly but i don't think my form likes variables. that might sound wierd but i cannot get them to work. I have even tried very simple things like field1.value = nNumber.value; i still get nothing. I use the form1.table1.row(nNumber).etc and it doesn't like it even when i just set var nNumber = 1. I have chosen variables in form properties tab and still nothing. I must be missing something somewhere.

Avatar

Level 3

I am trying to put a date/time in my Table in the first cell. However, everytime i Addinstane(1) the date/time changes for all the rows. How do i get the date time to only change the current row?

also why doesn't this work

var nRow = var nRow = Table1._Row1.count;

Table1.Row1[nRow].Cell1.rawValue = DateTimeField1.rawValue

my table have only two rows. header and row1. when i add a new row it is now call Row1[0] and Row1[1]. But when i write it out like that it doesn't work?!?!?!?! I don't get why.

Then i could just change the rawValue of Row1(nRow).Cell1.rawValue = Date/time or whatever right? That would stop every row from changing?? Is there another way to addInstance without having it do this?