Question Details

avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

Need help getting a form field on Acrobat to do a conditional equation (if, then).

I am trying to set up a form so that it will compare the total credit against total debit and if credit is higher than debit, return the difference to one form field and if credit is lower than debit, return that difference to a different form field.


Anita Crum 547 days ago


2 Answers

Voted Best Answer

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

This can be done. If you have a consolidated calculation (put all calculations into one single script, attaching it to a field which is not even part of the calculation), you can add the following code (you will have to adjust the field names):


var cre = this.getField("inCredit") ; // credit greater than debit
var deb = this.getField("inDebit") ; // debit greater than credit

var totcredit = this.getField("totalCredit") ; // total credit
var totdebit = this.getField("totalDebit") ; // total debit

var diff = totcredit.value - totdebit.value ; // that's the difference
cre.value = "" ; // clear the fields
deb.value = "" ;
if (Math.abs(diff) > 0.00001) {
if (diff > 0) {
cre.value = diff ;
} else {
cre.value = diff ;
}
}

Note that neither field will show a value if the balance is 0; if you want another behavior for balance = 0, you would add an "else" path to the first comparison.

Because of the way numbers are represented and calculated in JavaScript, there may be a little difference, even if they are essentially the same, we consider any value smaller than 0.00001 to be 0.

And that should do it.

Hope this can help.

Max Wyss.


By Max Wyss answered 547 days ago  |   Comments (0)  |  New Comment

avatar

  |   Report
Was this answer helpful?  
1
0

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

Have you read this article?
http://acrobatusers.com/tutorials/con...


Thom Parker answered 547 days ago  |   Comments (0)  |  New Comment

avatar

  |   Report
Was this answer helpful?  
1
0


Download
Acrobat XI trial

Get the trial now


Other Questions Needing Answers