4 Replies Latest reply on Jun 2, 2008 9:02 AM by MarkWalsh

    Calculating Based on Checkbox Value

      ok I have simple situation, one checkbox and one text field. If the check box is checked, I want the value of the text field to be 3(just an example).

      I'm new to formcalc
      on the text field calculate, this is what I have, and ofcourse it doesn't work.

      If cbquickbooks.value=1 then(txtquickbooks.rawValue=3)

      Thanks!
        • 1. Re: Calculating Based on Checkbox Value
          Patrick Leckey Level 3
          Use the rawValue of your checkbox instead of just value. If memory serves, the value will be the checkboxs exported value as opposed to a boolean value.

          In JavaScript (you can change the drop-down from FormCalc to JavaScript) it would be:

          if ( cbquickbooks.rawValue == true )
          {
          txtquickbooks.rawValue = "3";
          }
          • 2. Re: Calculating Based on Checkbox Value
            Okay - I'm new as well - in Acrobat Professional 8 - forms (since some folks are on Macs) - can you create a calculated field for say an expense report for mileage.
            The text field folks would put in the miles they drove - then I want another field to be able to show the total expense - using the mileage rate (say $.505)
            Any help?
            (and if it can't be done in acrobat forms- can it be done in LiveCycle designer for windows? How?
            Thanks for any suggestions
            • 3. Re: Calculating Based on Checkbox Value
              Patrick Leckey Level 3
              It can be done, quite simply, in both AcroForms and XFA (LiveCycle Designer) Forms using JavaScript.

              Here is the JavaScript reference:
              http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf

              If you don't already know even a little JavaScript, I would strongly urge you to read some basic JavaScript tutorials before working with JavaScript inside Acrobat.
              • 4. Re: Calculating Based on Checkbox Value
                MarkWalsh Level 4
                No need to use Javascript here, a simple calculation will do the trick.

                Just define your calculation to be the product of the Mileage and Rate fields (You need to create a separate field for the rate, but if you don't want the users to edit it, you can make it read only, or not even make it visible at all)

                If you want to do a total sum of multiple mileage fields, just name them 'Mileage.1", "Mileage.2", "Mileage.3"...and so on (the dot is important), and make your mileage total field a calculated sum of "Mileage" field (no dot here) Then use that for the calculation to multiply times your rate value.