Tables:
/------------------/
/adinstance /
/----------------/
/--------------------------/-----------------------------------/ /----------------------------/---------------------------/
/ DROP DOWN / Power Rating / / # of 110 circuits / # of 208 circuits /
/ (110 or 208) / (input any #, eg 500) / /-----------------------------/-------------------------/
/----------------------/-----------------------------------/ / x / y /
/----------------------------/-------------------------/
I got the math function to determine the # of 110 and 208 circuits and thats OK:
Math.ceil ((Table2.Row2.Cell(1 or 2).rawValue / 110 or 208) / 20 (for 110) or 30 (for 208)
Its getting quite difficult for me because of the drop down box thing since on the first instance suppose you get (3) 110 circuits, when you add another instance and it gives you another 2 circuits, those two results would add up and be 5 110 circuits, the same thing with the 208 circuits and so on...
I need general guidelines please!!! I included a test file with the basic layout just in case. Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Samual,
In the dropdown you have "specified values" in the Object/Binding tab. So when the user sees and selects "120"; Acrobat also sees "120" as bound data.
This is a very powerful aspect of dropdowns, because you could set the dropdown item to "120 volts" and then keep the specified value to "120". The user sees 120 volts, but behind the scene the .rawValue is 120.
Therefore in the script I can access the .rawValue, which is "120".
If you are copying this back into a real form, then make sure that the dropdown also has specified values in the Binding tab.
Hope that helps,
N.
Views
Replies
Total Likes
Hi,
The calculation needs to loop through all of the instances of row2 and determine what each row is (120 or 208).
Attached is a sample.
var nIndex = Table1.Row2.instanceManager.count;
var vCircuits = 0;
for (var i=0; i<nIndex; i++)
{
var valor = xfa.resolveNode("Table1.Row2[" + i + "].Cell1").rawValue;
if (valor == 120)
{
vCircuits += Math.ceil ((xfa.resolveNode("Table1.Row2[" + i + "].Cell2").rawValue / 120) / 20);
}
}
this.rawValue = vCircuits;
Hope that helps,
Niall
Niall, Thank you very muchh! Im so grateful to you !
But there is just one little thing that it is supposed to do.
(1) 120 circuit can take up to 2400 watts.
(1) 208 circuit can take up to 6240 watts.
Thats why I used the math ceil op.
That means that if on the first instance for 120 volts you input 500 you get one circuit but if on a second instance you input 500 more you still can use the same circuit from the first instance.
So I may keep adding power on the same 120 circuit till it hits 2401, thats when you add another 120 circuit and it should display 2 circuits on the other table. The third circuit comes when the sum of 120 volts power ratings hit 2400 x 2 plus one more watt.
The same goes for 208.
Im really thankful for your help on this. THANKS!
Views
Replies
Total Likes
Hi Samuel,
OK, now I have a better grip on what you are trying to do.
We can just move the calculation out of the loop:
var nIndex = Table1.Row2.instanceManager.count;
var vCircuits = 0;
for (var i=0; i<nIndex; i++)
{
var valor = xfa.resolveNode("Table1.Row2[" + i + "].Cell1").rawValue;
if (valor == 120)
{
vCircuits += xfa.resolveNode("Table1.Row2[" + i + "].Cell2").rawValue;
}
}
this.rawValue = Math.ceil ((vCircuits / 120) / 20);
Now vCircuits works out the total watts and then the math.ceil determines how many circuits are required.
Just to note that in the loop, the "+=" adds the row value to the current (no pun intended) row value to the vCircuits, so that it is increasing each time the loop complies with the if statement.
I think this is working as intended.
Good luck,
Niall
Views
Replies
Total Likes
Thank you Niall!!!
Just a little doubt. How are you reading the drop down choice??
xfa.resolveNode("Table1.Row2[" + i + "].Cell1").rawValue;
Views
Replies
Total Likes
Hi Samual,
In the dropdown you have "specified values" in the Object/Binding tab. So when the user sees and selects "120"; Acrobat also sees "120" as bound data.
This is a very powerful aspect of dropdowns, because you could set the dropdown item to "120 volts" and then keep the specified value to "120". The user sees 120 volts, but behind the scene the .rawValue is 120.
Therefore in the script I can access the .rawValue, which is "120".
If you are copying this back into a real form, then make sure that the dropdown also has specified values in the Binding tab.
Hope that helps,
N.
Views
Replies
Total Likes
Thanks!
Views
Replies
Total Likes