6 Replies Latest reply on Mar 13, 2014 3:59 PM by Donald9037

    check boxes

    Donald9037

      1.jpg

       

      The picture above is a part of an invoice I have created using Adobe Acrobat XI Pro... I have incorporated the checkbox next to the senior discount field to subtract the discount from the total field when the box is checked, and the script works to perform this task.  However, the discounted amout shows up even if the box remains unchecked, but does not subtract it from the total until the box gets checked.  I am basically running 2 scripts to make this work.  1.  In the properties of the discount box, under the calculate tab, I have ticked "Simplified Field Notation" with a simple script "SubTotal*-.03" entered to calculate a 3% discount.  Also, under the actions tab, the "select trigger's" drop down box reads "Mouse up" and "select action" is set to "Run a JavaScript" which is also reflected in the Actions box.  When I click on edit to bring up the java script, it reads like this:

       

      // Mouse Up script for Check Box1

      if (event.target.value !=="Off"}{

        // set Senior field

        this,getfield("Senior").value=SubTotal8-.03;

      } else {

         // not checked no Senior

         this.getfield("Senior").value=0;

      }

       

      As I said, the discount works, but the discount shows whether the box is checked or not, but only subtracts it from the Total when the box IS checked.  I would like this to show a zero balance when the check box is unchecked.  Any Help would be appreciated.  Thanks

      (note: the checkbox on the coupon line no longer exists)

        • 1. Re: check boxes
          try67 MVP & Adobe Community Professional

          Did you define a variable called "SubTotal8"? If not, then your code is incorrect.

          If this is the name of a field, then you need to access its value like so:

          this.getField("SubTotal8").value

          • 2. Re: check boxes
            Donald9037 Level 1

            Thank you for your reply, Gilad... the SubTotal8 was a typo... the 8 was not supposed to be there.  I apologize for that... I am assuming the code is correct then, but at the same time, is there a way to keep the discount total at a zero if the box is not checked... Right now, the discount shows automatically all the time, but only takes it off the discount off the Total when the box is checked... Thank you in advance for any insight you can give.  Don

            • 3. Re: check boxes
              try67 MVP & Adobe Community Professional

              Sorry, I don't quite follow. So if it's just "SubTotal", where are you defining that variable?

              • 4. Re: check boxes
                Donald9037 Level 1

                Thank you again for your assistance with this, Gilad D... I hope that I can explain this correctly so you will understand what I have done here... In the diagram above, you will see a Senior Discount box with a checkbox in it.  On the right hand side of the checkbox is the field where the discount computation appears. I named it simply, "Senior".   Under Form editing, I right click in that computation field (Senior) and clicked on properties... under the text field properties window, there are 8 tabs, 2 of which i have edited.  The first tab is the Actions tab... I have set that to show a "select trigger" of "Mouse Up" and the "Select Action" is set to "Run a Java Script".  That Jave Script entered reads as follows...

                 

                // Mouse Up script for Check Box1

                if (event.target.value !== "Off") {

                    // set Senior field

                    this.getField ("Senior").value = SubTotal*-.03;

                } else {

                     // not checked no Senior

                     this.getField("Senior").value = 0;

                }

                 

                The second tab I edited is the Calculate Tab... I ticked the "Simplified field notation" bullet and in that field i put in "SubTotal*-.03".

                 

                While this script does calculate correctly and works with the coinsiding check box, the "Senior" field always shows the discount, even though it doesnt subtract it from the total unless the check box is checked.  I would like the "Senior" field to show a zero total when the check box is unchecked and to only calculate the discount when the checkbox is checked.

                 

                I hope this isnt too confusing, as I am real new to working with java script, and really havent much of a clue as to what i am really doing... LOL.  Any help you could continue to educate me with would be highly appreciated.  Thanks again for your assistance, Gilad D.  Don

                • 5. Re: check boxes
                  try67 MVP & Adobe Community Professional

                  You can't access a field's value in a script by simply writing its name. It

                  has to be done by using the getField method and the value property, as I've

                  shown earlier.

                  • 6. Re: check boxes
                    Donald9037 Level 1

                    Ok, I am gonna post a diagram of what it looks like without a checkmark and with a checkmark... you should notice that the discount amount shows up in both instances but only takes the discount out of the total when the checkbox is checked.  We would like the discount to show a "0.00" when the checkbox is not checked.  Also, is there a certain scripting we need to use to make the discount round to the nearest whole dollar so we discount only in whole dollars?  As for the scripting details already in place, please refer to my last post for specifics.  Thank you.  Donald

                     

                    2.jpg3.jpg