I have a form where I am trying to calculate the unit * unit price to get a total.
There are 23 lines altogether. From the totals, I need to get a subtotal, then apply taxes to the subtotal, and finally a grand total.
My problems are these: If I only fill in line 1, the "P.S.T." and "G.S.T." fields remain blank. If I fill in more than line 1, the taxes are calculated, but if I change either the unit value or the unit price value, the taxes are not calculating to the correct value.
Any help would be appreciated.
Here are my scripts:
var a = this.getField("QO1");//quantity
var b = this.getField("UnitPrice1");//unit price
event.value = a.value*b.value;//quantity * unit price
if(event.value==0)event.value=""
//my form has a total of 23 lines as above
////////////////////////////////////
my subtotal script is as follows:
var a = this.getField("Total1").value;
var b = this.getField("Total2").value;
var c = this.getField("Total3").value;
var d = this.getField("Total4").value;
var e = this.getField("Total5").value;
var f = this.getField("Total6").value;
var g = this.getField("Total7").value;
var h = this.getField("Total8").value;
var i = this.getField("Total9").value;
var j = this.getField("Total10").value;
var k = this.getField("Total11").value;
var l = this.getField("Total12").value;
var m = this.getField("Total13").value;
var n = this.getField("Total14").value;
var o = this.getField("Total15").value;
var p = this.getField("Total16").value;
var q = this.getField("Total17").value;
var r = this.getField("Total18").value;
var s = this.getField("Total19").value;
var t = this.getField("Total20").value;
var u = this.getField("Total21").value;
var v = this.getField("Total22").value;
var w = this.getField("Total23").value;
event.value = a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w;
if(event.value==0)event.value="";
////////////////////////////////////////////
I then have two scripts for calculating taxes as follows:
var a = this.getField("Subtotal").value;
var b = .08;
event.value = a * b;
if(event.value==0)event.value="";
///////////
var a = this.getField("Subtotal").value;
var b = .05;
event.value = a * b;
if(event.value==0)event.value="";
////////////////
Then my script to get the value of subtotal and the two tax fields as follows:
var a = this.getField("Subtotal").value;
var b = this.getField("P.S.T.").value;
var c = this.getField("G.S.T.").value;
event.value = a+b+c;
if(event.value==0)event.value="";
About your problem: check the field calculation order. It sounds like there's a problem with it.
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com