Use formatting display to hide number form fields with value of zero
I know I've seen this somewhere else in this forum, but I can't find it.
I have a number field that is calculated based on the value of two other fields. However, when the other fields are empty or the calculation otherwise equals zero, I want to hide the form field so that the zero is not visible. I think I've got the code right, but it doesn't seem to work. This is the code I'm using:
var field1 = this.getField("Field 1").value;
var field2 = this.getField("Field 2").value;
var total = field1 * field2;
if ( total!=0 )
{
event.target.value = total;
event.target.display = display.visible;
}
else
{
event.target.display = display.hidden;
}
This code is used on the calculations for the field I want to hide. All three fields are specified as number fields. What am I missing?
Edited to add: The field I want to hide is used in other fields and calculations, so I want to keep the zero value, but I want the field to appear blank if the value is zero. This is so the form can be printed and used manually.
Thanks in advance for any suggestions!
