Skip to main content
Participant
Feb 10, 2017 12:20 AM UTC
Answered

Trying to multiply two fields on a purchase req and have zeros be blank

I am new to Javascript programming in adobe.  I have a purchase req that needs to multiply the qty and the unit cost to get an extended cost.  I know I can do this in a simple calculation, but I also want fields that are zero to return blank.  the code I have so far is:

event.value=(this.getField("QtyRow1").value * this.getfield("UnitCostRow1").value);

If(event.value==0) event.value = "";

neither stablemen is working.  The first does not seem to calculate and the second give me the missing; before statement 2 error...any help you can give would be great.

This topic is closed to new replies. Start a new post to keep the conversation going.
JR Boulay
JR BoulayCorrect answer
Community Expert
Feb 10, 2017 10:39 AM UTC

event.value=(this.getField("QtyRow1").value * this.getField("UnitCostRow1").value);

If(event.value==0) {event.value = "";}

Acrobate du PDF, InDesigner et Photoshopographe

4 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
Feb 10, 2017 10:39 AM UTC

event.value=(this.getField("QtyRow1").value * this.getField("UnitCostRow1").value);

If(event.value==0) {event.value = "";}

Translate
Acrobate du PDF, InDesigner et Photoshopographe
Participant
Feb 10, 2017 4:07 PM UTC

Thanks...this seemed to solve it!  Appreciate your help.

Translate
try67
Community Expert
Community Expert
Feb 10, 2017 9:32 AM UTC

There's an error in your code. Did you check the JS Console?

Translate
Joel Geraci
Community Expert
Community Expert
Feb 10, 2017 12:51 AM UTC

You'll want to actually leave the calculated value as zero. You can set how "0" displays in a custom format script like the following.

if (event.value == 0) {

    event.value = "";

}

So leave your calculation (the first line, where it is. Move the second line to the Custom Format Script in the other tab.

Translate