Copy link to clipboard
Copied
Hello!
I'm new to javascript, so please excuse my lack of knowledge . The first field on my form can be blank or have a numeric value. That field plus about 20 others will be added together to result in a grand total. Based on what the number in that first field is, I've written a calculation script in another field to determine whether the number in that field is greater than, less than, or equal to a specific number. That's working great, except that when the form is opened, the specific number from the calculation script is showing up in that calculated field. I want the calculated field to be blank unless something there is an amount in the grand total on the form. The number printing in the calculated field (which happens to be the last field on the form) is currently -12.00 until a number is entered in any of the 20 or so fields; as soon as any of them has a value entered, I want the calculated field to begin showing it's calculated number. Could I use a validation script to do that? I've tried several with no luck.
Thanks in advance for any assistance you can give me!
Kim
Copy link to clipboard
Copied
You can add a condition to the script so that it doesn't display anything until there's a value in the total field.
Something like this:
if (this.getField("Total").valueAsString=="") event.value = "";
else {
// perform rest of calculation
}