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

if else statement help

tlcollins
Registered: Oct 20 2008
Posts: 13

I am preparing a form in Adobe Acrobat 9, and I need to perform a calculation that would require an "if-else" statement (I think!)

If the user enters a GST number (GSTNum), then I want the subtotal (TotalDues1) multiplied by the GST rate (GSTRate1). This calculation will take place in the field "Text4"

This is what I have, but it doesn't seem to be working:

var f=this.getField("GSTNum");

if (f.value<=0){event.value=0}
else{event.value=TotalDues1*GSTRate;}

I am very green to Javascript, so would appreciate any help!!

Thanks,
Tracy

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
And what is the value of the variable GSTRate and the TotalDues1 set?

If they are fields, you need to get their field vlaues.

George Kaiser

tlcollins
Registered: Oct 20 2008
Posts: 13
GSTRate1 is a field, manual entry of the rate will be entered in the form. TotalDues1 is a calculation field, which is the subtotal of other cells. It is a hidden field, only for calculation purposes.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You need to get the fields and values before you can use them:

// get the GST Num field object
var oGSTNum = this.getField("GSTNum");
// get the Total Dues field object
var oTotlaDues = this.getField("TotalDues1");
// get the GSTRate field object
var oGSTRate = this.getField("GSTRate1");

if (oGSTNum.value <= 0){
// if GSTNum less than or equal to zero the event value is zero
event.value = 0;
} else {
// else the event value is total dues times GST rate
event.value = oTotalDues.value * oGSTRate.value;
}

George Kaiser

tlcollins
Registered: Oct 20 2008
Posts: 13
IT WORKS!!!

Thank you so much for your help.