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

How To Write Script For Sum + Multiplications?

buramiko
Registered: Mar 11 2009
Posts: 8

I have form fields named Qty1, Qty2, Qty3 and I'd like to mutiply each Qty with a set of fixed numbers - 128, 26, and 35 respectively, and then calculate the sum of all 3 results?
i.e. (Qty1*128)+(Qty2*26)+(Qty3*35) ?

I tried this :

var a = this.getField(Qty1).value;
var b = this.getField(Qty2).value;
var c = this.getField(Qty3).value;
event.value = (a.value * 128) + (b.value * 26) + (c.value * 35);

But doesn't work... please help?

nixopax
Registered: Feb 6 2009
Posts: 105
Try this:

var a = this.getField("Qty1").value;var b = this.getField("Qty2").value;var c = this.getField("Qty3").value;event.value = (a * 128) + (b * 26) + (c * 35);

You forgot to put your getField names in quotes.
You also were attempting to get the value of a field object when you had predefined the variable to have it assigned as the variable value already.
buramiko
Registered: Mar 11 2009
Posts: 8
COOL~~~ Thanks alot!!!