Conditional fee calculation in document level javascript
Hi, I'm trying to create a document-level javascript to calculate three fields with conditions. The three fields are "LicenseFee", "ServiceFee", and "Total". The "LicenseFee" is the only one not read-only; the other two fields will autocalculate based on the number entered in "LicenseFee".
I'd like the behavior to go as follows: when "LicenseFee" is empty, "ServiceFee" and "Total" are also empty. When an integer is entered in "LicenseFee" (for example, 120.00), "ServiceFee" will multiply that number by .025 and add 2.00. "Total" will then add "LicenseFee" + "ServiceFee".
This what I have so far - up front I am a novice to javascript:
function FeeCalc()
{
var Licensefee = this.getField("LicenseFee").value
var ServiceFee = this.getField("ServiceFee").value
var Total = this.getField("Total").value
if (LicenseFee='') {
Service='';
Total='';
}
else
{
ServiceFee=(LicenseFee * .025) + (2.00);
Total=LicenseFee + ServiceFee;
}
}
I appreciate any and all assistance! Thanks so much! Bill
