Populating from one table cell in one table to another cell in another table - confusing results

Avatar

Avatar

SunsV

Avatar

SunsV

SunsV

10-07-2014

Hi, really hope someone can help because I feel like I'm almost there... just not quite!

Here's what I have:

Two tables. One is called 'plantable' - this is an expanding table in so much as the user can click a button and it will add a new empty row. Within this row there is a button to remove the row (working fine), six text field cells where users can add text. Two of these text cells are called 'wb' and 'better' - this is important as they come into play later. There's also a button called 'Send to Review' on the same row.

This button does two things: It adds a new Row in a separate table called 'review table'. 'reviewtable' operates similarly to 'plantable'. It is expanding (so there's an 'add row' button) and each row consists of a remove button which removes that particular row, along with five text field cells - two of which are called 'wb' and 'better'

This is what I would like to happen: The user adds several entries (rows) in the 'plantable'. They have the option of adding one of these rows to the 'reviewtable' - if they do this it will auto-populate the text fields for 'wb' and 'better' in the newly created row in the 'reviewtable'. The user can also go directly to the 'reviewtable' and add a new row (completely independent of the 'plantable') and fill in the text fields as they require.

This is what is actually happening: It all works... apart from the fact that whichever 'add to review' button the user presses in the 'plantable' row, a new row is created in the 'review table' but it always pulls the data from the cells of the top-most row in the 'plantable'. For example, I have a plantable with three rows, a, b, c (each row has an 'add to review' button). Each row has text for the 'wb' and 'better' text cells - say, a-wb, a-better, b-wb, b-better, c-wb, c-better. Even if I click on the 'add to review' button in row c, the reviewtable will always add a new row and populate it with the contents from row a. If I click on the same button again it will add a new row and fill it with the contents of row b. If I keep pressing the button it will add more and more rows but they become blank. Also, if the user has added new rows independently to the reviewtable it won't keep the order, so instead of having a row with empty fields followed by say row a then row b, row a will always come first, followed by row b followed by the empty row. I just want them to be viewed in the order the user has added them to the reviewtable. Not what I want to happen.

Here's my code.

Code for adding a new row to plantable (I think this is correct, but placing it here so you can see):

plantable._planrow.addInstance(0);

Code for adding a new row FROM a row in plantable TO a new row in review table (it also adds a dialogue box before proceeding which is the first two lines of code):

var button = xfa.host.messageBox("You are about to ADD this entry to the REVIEW section. Do you wish to proceed?", "Add to Review Section", 1, 2);

if (button == 4)

{form1.Review.reviewsub.reviewtable._planrow.addInstance(0);

var vCol1 = this.resolveNodes("form1.plan.plansub.plantable.planrow[*].better");

var vCol2 = this.resolveNodes("form1.Review.reviewsub.reviewtable.reviewrow[*].better");

var vCol3 = this.resolveNodes("form1.plan.plansub.plantable.planrow[*].wb");

var vCol4 = this.resolveNodes("form1.Review.reviewsub.reviewtable.reviewrow[*].wb");

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

             vCol2.item(i).rawValue = vCol1.item(i).rawValue;

             vCol4.item(i).rawValue = vCol3.item(i).rawValue;

}

}

Can anyone help me with this please as I don't really understand where I am going wrong.

Many thanks, Sunil

View Entire Topic

Avatar

Avatar

SunsV

Avatar

SunsV

SunsV

10-07-2014

sorry to bump this, but does anyone have an idea? Being a bit stuck here.