Previous | Next | (P-PDF) JavaScript
Topic: How to print a blank in a field if calc is 0
Conf: (P-PDF) JavaScript, Msg: 32390
From: george
Date: 1/8/2002 06:36 PM
> I am doing some calculations in some fields
> sometimes the result is 0. I dont want to print a
> zero I would like to print a blank. How can I do
> this in javascript?
You have to use a custom Calculation script. For example, if you want to add the two fields named "text1" and "text2", you might do something like:
// Get field values, multiplying by 1 to ensure
// we're dealing with numbers and not strings
var v1 = getField("text1").value * 1;
var v2 = getField("text2").value * 1;
// Perform calculation
var sum = v1 + v2;
// Display only if result is non-zero
if (sum != 0) event.value = sum;
else event.value = "";
George