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

javascript help requested .... PLEASE!!

kerrykew
Registered: Nov 25 2008
Posts: 19
Answered

Hello,
I have been trying to add a group of fields IF there is a specific value in another group of fields. I have the following code that does work as expected:

var gSum = 0;
{if ((xfa.resolveNode("xfa.form.form1.#subform[0].FuelType[0]")).rawValue == "Gasoline")
gSum = gSum + ((xfa.resolveNode("xfa.form.form1.#subform[0].BilledGallons[0]"))).rawValue
}
event.value = gSum;

My problem is there are 24 occurrences of the "FuelType" and "BilledGallons" fields. How can I create a loop that will check them? Any help is VERY MUCH appreciated.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Your syntax is wrong!
Try...

var gSum = 0;if (xfa.resolveNode("form1.#subform[0].FuelType[0]").rawValue == "Gasoline"){gSum = gSum + xfa.resolveNode("form1.#subform[0].BilledGallons[0]").rawValue;}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

kerrykew
Registered: Nov 25 2008
Posts: 19
Thanks for your help! I am a beginner so I really appreciate the assistance. My only remaining issue is that I have several occurences of the field FuelType and BilledGallons. Is there a way to create a loop that will check occurrences FuelType[0]...FuelType[n] and if the condition is met, add the value from BilledGallons[n]?

Thanks again for your help!
Kerry
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Yes, I just posted an answer for this here...

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=20072

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs