Skip to main content
Participant
February 10, 2017
Answered

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

  • February 10, 2017
  • 3 replies
  • 612 views

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 has been closed for replies.
Correct answer JR Boulay

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

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

3 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
February 10, 2017

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

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

Acrobate du PDF, InDesigner et Photoshopographe
Participant
February 10, 2017

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

try67
Community Expert
Community Expert
February 10, 2017

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

Joel Geraci
Community Expert
Community Expert
February 10, 2017

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.