Hello,
I made a table in lifecycle designer that uses the instance manager to add rows.
I want to write code that will loop through each of the instances and perform a comparison. I would like the code to examine the index field. If the index field = 2, then return the value of the num amount field.
This is what I have tried so far and it does not work.
var var
var
oFields = xfa.resolveNodes("Subform1[*].index1");
var
nNodesLength = oFields.length;
for
(var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)
{
if (oFields.item(nNodeCount).rawValue ==2)
{
form1.#subform[2].Table5.Row5.NumericField1.rawValue
= form1.Page1.Subform1.Capital1.Capital1.detail.numAmount.rawValue;
}
break;
}
Views
Replies
Total Likes
Here is a more lengthy definition of my problem. I hope someone can help.
1. I have a table that will allow the user to add rows when they click the plus button. Here is the code
----- form1.Page1.Table7.#subformSet[0].#subformSet[1].detailHeader2.Button2::click: - (JavaScript, client)
_detail.addInstance(this.parent.index);
//Invoke the recalculate method to include the field values from the added row in calculations.
xfa.form.recalculate(1);
2. The table also has a button to delete rows. Here is the code
----- form1.Page1.Table7.#subformSet[0].detail.Button2::click: - (JavaScript, client) --------------
// Invoke the Instance Manager to remove the current instance of the detail subform.
_detail.removeInstance(this.parent.index);
// Invoke the recalculate method to update the form calculations.
xfa.form.recalculate(1);
3. The table has a drop down list named txtPartNum and that allows you make a selection. Once you have made the selection a script populates other fields in the same row. The Drop Down list contains this code:
----- form1.Page1.Table7.#subformSet[0].detail.txtPartNum::initialize: - (JavaScript, client) ------
// Populate the part number Drop-down List.
partNoScript.populatePartNo(this);
----- form1.Page1.Table7.#subformSet[0].detail.txtPartNum::change: - (JavaScript, client) ----------
// Populate the description and the unit price when we change the part number.
partNoScript.getDesc(xfa.event.newText, txtDescription, numUnitPrice, index1);
4. The following script populates the following fields:
txtPartNum,
txtDescription,
numUnitPrice,
index1
----- form1.#subform[2].#variables[0].partNoScript::partNoScript - (JavaScript, client) ------------
// This script object controls the interaction between the part number, description and unit price fields.
// When you fill the partNo, partDesc and partPrice arrays, make sure they have the same number of array indices in
// each array i.e. for every part number, there should be a matching description and price.
// Array of part numbers.
// This script object controls the interaction between the part number, description and unit price fields.
// When you fill the partNo, partDesc and partPrice arrays, make sure they have the same number of array indices in
// each array i.e. for every part number, there should be a matching description and price.
// Array of part numbers.
var partNo = new Array(" ",
"Company Labor - Regular Hours",
"Company Labor - Overtime Hours",
"Company Engineering - Regular",
"Company Engineering - Overtime",
"Company Burden",
"Subcontract Labor",
"Subcontract Engineering",
"Subcontract Material",
"Subcontract Equipment",
"Subcontract Labor & Material Bid",
"Purchased Materials",
"Materials from Inventory",
"Transportation Equipment",
"Miscellaneous Tools Shope and Garage",
"Construction Equipment",
"Rental Equipment",
"Permits",
"Legal Fees",
"Other Miscellaneous");
// Array of part descriptions.
var partDesc = new Array(" ",
"1221.9922",
"1222.9922",
"1221.9922",
"1222.9922",
"1221.9922",
"1232.9933",
"1232.9933",
"1232.9933",
"1232.9933",
"1232.9933",
"1201.99119",
"1201.99119",
"1201.99139",
"1201.99139",
"1201.99139",
"1201.99139",
"1250.994",
"1250.994",
"1250.994");
var partPrice = new Array(null,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0);
var partDesc2 = new Array(1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20);
var partDesc3 = new Array(" ",
"CLIN ",
"CLIN ",
"CLIN",
"CLIN",
"PO, NTP or C#",
"PO, NTP or C#",
"VENDOR NUMBER",
"CLIN",
"CLIN");
// Populate the part number Drop-down List.
function populatePartNo(dropdownField)
{
var i;
for (i=0; i < partNo.length; i++)
dropdownField.addItem(partNo[i]);
}
// Populate the description and unit price fields.
function getDesc(partNumber, descField, itemPrice, partNumber1, partNumber2)
{
var i;
for (i = 0; i < partNo.length; i++) // Go through the entire list of part numbers to find the one that is currently selected.
{
if (partNo[i] == partNumber) // When we find the part number currently selected.
{
descField.rawValue = partDesc[i]; // Put the description in the description field
itemPrice.rawValue = partPrice[i];
partNumber1.rawValue = partDesc2[i];
partNumber2.rawValue = partDesc3[i];// and put the unit price in the unit price field.
break; // No need to go further if there is a match.
}
}
}
Problem. I want to add a new field to
a. search the table
b. Look at the value of index1
c. If the value = 2, return the value of in the numAmount field.
The following if statement does only part of what I want. But only if the value is 2 on the first row. Not any of the other rows belowit.
----- form1.#subform[2].Table5.Row5.CL1::calculate: - (FormCalc, client) ---------------------------
if (form1.Page1.Table7.#subformSet[0].detail.index1 == 2)
then
$.rawValue = form1.Page1.Table7.#subformSet[0].detail.numAmount.rawValue
endif
I need a for loop that will go through each instance row that the user has added.
Views
Replies
Total Likes
Views
Likes
Replies