Skip to main content
Participant
September 8, 2008
Question

How to subtract in a calculation in Acrobat Pro 9

  • September 8, 2008
  • 6 replies
  • 50863 views
I'm building a pdf with some calculations. I can do a 'sum, product,average,minimum,maximum'. But how do i subtract 2 fields?
    This topic has been closed for replies.

    6 replies

    Participant
    March 20, 2009
    How would you write this if you were wanting to subtract dates? I'm using Acrobat 9 as well. Thank you!
    Participant
    March 19, 2009
    George - thank you so much! I didn't ask the question, but I certainly benefited from your assistance. Thanks so much! -dave
    Participant
    September 9, 2008
    works!
    Participant
    September 8, 2008
    your the best, gonna try it out!
    Inspiring
    September 8, 2008
    I should not have said you *need* to use JavaScript, because you can also use the "simplified field notation" option, but as you come to do more than the simplest of calculations, JavaScript is what you'll need.

    If you want to use the simplified field notation option, you'd enter:

    Text1 - Text2


    but you'd replace Text1 and Text2 above with the names of your fields.

    George
    Participant
    September 15, 2022

    I was unable to subtract using the guidance you provided. Do I need to add an equal sign or something?

    Inspiring
    September 8, 2008
    You will need to use JavaScript in a field's custom calculation script. For example:

    // Get first field value
    var v1 = getField("Text1").value;

    // Get second field value
    var v2 = getField("Text2").value;

    // Set this field value equal to the difference
    event.value = v1 - v2;

    You would replace "Text1" and "Text2" with the names of the fields you've set up.

    George
    Inspiring
    November 6, 2020

    I guess I'm missing something. I can't get this to work. Here is the script that I am using.

    v1 = getField("Subtotal").value;
    v2 = getField("TotalDiscount").value;
    TotalDue.value = v1 - v2;

     

    Any help would be appreciated.

     

    Jack

     

    Bernd Alheit
    Community Expert
    Community Expert
    November 6, 2020

    Use this:

    event.value = v1 - v2;