Greetings.
I'm trying to do something that seems like it should be quite simple. I have three form fields in my pdf. One of them is set to calculate the product of the other two for its value. We'll call the field that does the calculation TotalPriceA and the fields that it multiplies are QuantityA and UnitPriceA.
Unfortunately, the form must be able to be filled out digitally or by hand, which means that the $0.00 that appears in TotalPriceA is a drawback, since it would be in the way if someone wants to pencil in the total theirselves.
Thus, my problem is that I want the $0.00 to be invisible unless it's more than 0 (i.e., if either of the other fields are filled in digitally).
Based on something I found in Stefan Cameron's blog, I generated this tiny bit of script and placed it in the "custom calculation script" under the "Calculate" tab of the TotalPriceA's properties:
if (TotalPriceA > 0) then
$.presence = "visible";
UnitPriceA * QuantityA;
else
$.presence = "invisible";
0;
endif
Unfortunately I don't know if this would work, because I get an error before it'll let me click Ok.
It tells me, most helpfully:
SyntaxError: syntax error
4: at line 5
Which is the line that contains
$.presence = "invisible";
Any ideas what's wrong with this? I'm very new to scripting results and I don't know if there might not be a much easier way to accomplishing my goals. A heads-up on what I've coded wrong or a totally different approach would be equally appreciated.
Thanks!
Setting the value for TotalPriceA to the empty string "" instead of 0 should keep you from getting $0.00 in the field. Try the following javascript in the "custom calculation script" under the "Calculate" tab for TotalPriceA:
//set up variables
var QuantityA=this.getField("QuantityA").value;
var UnitPriceA=this.getField("UnitPriceA").value;
var CalcTotalPriceA=QuantityA * UnitPriceA;
//set TotalPriceA field
TotalPriceA = this.getField("TotalPriceA");
if (CalcTotalPriceA > 0){
TotalPriceA.value = CalcTotalPriceA;
}else{
TotalPriceA.value = "";
}
Good luck,
Naomi Basickes
Appligent, Inc
www.appligent.com