Avatar

Level 3

Hello,

I am having some problems in using InstanceManager (dynamic tables). I try to add and delete new rows by using checkboxes. If a checkbox gets clicked a new row, with a value given from the checkbox, appears. If a checkbox gets deactivated, then the row, it has created, is going to be removed.

I use addInstance to add new lines into the table. In this case new line apperas always at the end of the table, which is just perfect! It is exactly the way I need it. But I have no idea how to pass over the value of my checkboxes right to the last line of my table.

I have tried to use moveInstance an it just messed up my form. (uploaded here: www.hs-augsburg.de/~nikg-fh/mypdf.pdf )

My Form:

1.png

My Code:

MyForm.page1.checkbox1::change - (JavaScript, client)

if (this.rawValue == "1")
{
var myInstance = xfa.form.MyForm.page1.MyTable._MyRow.addInstance(1);
var fromIndex = xfa.form.MyForm.page1.MyTable._MyRow.index;
var toIndex = myInstance.index;
// Value of col. "CheckBox-Value"
    xfa.form.MyForm.page1.MyTable.MyRow.checkboxValue.rawValue = "CheckBox 1"; // <<<<<HERE IS THE PROBLEM!!!!!
// Value of col "fromIndex"
    xfa.form.MyForm.page1.MyTable.MyRow.fromIndex.rawValue = fromIndex;
// Value of col "toIndex"
    xfa.form.MyForm.page1.MyTable.MyRow.toIndex.rawValue = toIndex;
// Move Row
    xfa.form.MyForm.page1.MyTable._MyRow.moveInstance(fromIndex, toIndex);  // <<<< Don't need to use this Method?!
}
else
{
var rowToDelete = xfa.form.MyForm.page1.MyTable._MyRow.index;
    xfa.form.MyForm.page1.MyTable._MyRow.removeInstance(rowToDelete);
    xfa.form.MyForm.page1.deletedRow.rawValue = rowToDelete + 1;
}




it just gets messed up with this code, because of moveInstance (all checkboxes have similar coding):

any checkbox clicked:

1.png

checkbox1 klicked

2.png

checkbox 2 klicked:

3.png

checkbox 3 klicked:

4.png