These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Delete/Add a table row without a button

vinsanity
Registered: Apr 12 2010
Posts: 5

Hi,

I was just wondering if it was possible to add or delete a table row without adding a button to the table row? For example, I was planning to put some code in the form:ready event where is a certain row is null, then I would just remove it from the table.

Any help would be appreciated.

Thanks,

Vinsanity

BigRedDog
Registered: Apr 20 2010
Posts: 7
I do it all the time. On my form, I have the user select the type of agency involved. If they select anything other than a Task Force, I disable that table and delete all the rows but one. Here is the function I use. The function takes two values, the name of the table and the setting which can be "readOnly" or "open". If the setting is "readOnly", it deletes all the rows but the last one, deletes the contents, and then locks those fields out. If setting is "open", it enables all the fields:

////////////////////////////////////////////////////////////////////////////////////////////////
// This function toggles the availability of tables passed to it.
// If the table is to be disabled it deletes the rows in a table that is passed in to it, keeping
// one last row, but disabling it and the add_row button. Otherwise it will enable the fields
// and the add_row button.
function toggleTable (tableName, setting) {
var buttonColor // Color of buttons for Add Row.
var redBox // Determines whether or not fields are mandatry, and thus display a red box.

// Set some preliminary variables buttonColor and redBox
if (setting == "open") { // Enable fields, make some mandatory, and set button color to gray
buttonColor = "212,208,200";
}
else { // Disable fields and set button colors to white.
buttonColor = "255,255,255";
}

// If the second row isn't empty, remove it. Keep doing it until you have one row left.
if (setting == "readOnly"){
while (xfa.resolveNode(tableName + ".ROW[1]") != null){
xfa.resolveNode(tableName).ROW.instanceManager.removeInstance(0);
} // End While
} // Endif

// Delete or enable the contents of the rows.
var oNodes = xfa.resolveNode(tableName).ROW.nodes;
var nodesLength = oNodes.length;
for (var i = 0; i < nodesLength; i++) {
if (setting == "readOnly"){ // if disabling table, delete contents of last row
oNodes.item(i).rawValue = null;
} // Endif
oNodes.item(i).access = setting;
} // End for

// Set Add_Row color and availability
xfa.resolveNode(tableName).parent.ADD_ROW.fillColor = buttonColor;
xfa.resolveNode(tableName).parent.ADD_ROW.access = setting;
} // End clearTable function.
Profy
Registered: Jul 15 2010
Posts: 19
Where do you put your script, on the Add rows button, or is it on a Radio button or Check box?
BigRedDog
Registered: Apr 20 2010
Posts: 7
For my purposes, I have it on a radio button.

You can look at the form itself here:

http://www.justice.gov/criminal/afmls/pdf/aca-current-form.pdf