Copy link to clipboard
Copied
I have nine fields and show/hide them. Three drop down to select Quantities. Three Text fields for the Item Price and three Total fields. What I was trying to figure out is, a way to use one field to show the Total amount of the Quantity fields and Item Price fields when visible. Not calculate the Quantity and Price fields when hidden.
Presently, I have fields to calculate each group of fields and use this script in the Total field, (it works but it's not exactly what I want to do)
var f = this.getField("ItemPrice1");
var g = this.getField("ItemQuantity1");
event.value = f.value * g.value;
What I'd like to accomplish is when ItemPrice1 and ItemQuantity are visible then to calculate that. When ItemPrice2 and ItemQuantity are visible then to calculate that. But, in the same Total field and reset the fields that would be hidden.
With my vast javascript knowledge (not), I've tried to put this script in the Total field, but guess what, it didn't work to calculate. Only the Item3 is calculated.
var f = this.getField("ItemPrice1");
var g = this.getField("ItemQuantity");
event.value = f.value * g.value;
var h = this.getField("ItemPrice2");
var i = this.getField("ItemQuantity");
event.value = h.value * i.value;
var j = this.getField("ItemPrice3");
var k = this.getField("ItemQuantity");
event.value = j.value * k.value;
I've been trying to find a solution on the internet and trying to make a script on my own but I just don't know enough. Can someone help me out. Is what I'm trying to do even possible?
Using Acrobat X Pro on a Mac.
Copy link to clipboard
Copied
How/when are you hiding the fields? And why not reset them at that moment?
If you do that then you could just check their value, not their display property, in your calculation.
If the value of the first pair is empty, you move on to the next set of fields, etc.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now