2 Replies Latest reply on Nov 7, 2011 8:49 AM by Thom Parker

    Need to auto-populate text field with value from radio button

    (Chelsie_Hall)
      I am using Adobe Acrobat 8 Professional. I don't know ANYTHING about Java Scripting, but need some fancy form functions.

      I have 3 radio buttons with different dollar values. When one is selected, I need a text field to contain that dollar value. AND I need to be able to perform a calculation with the dollar value in that text field. EXAMPLE BELOW.

      ()Membership1 $20
      ()Membership2 $30
      ()Membership3 $40

      MembershipDues _____
      ApplicationFee _____
      Total _____

      Can anyone walk me through this in elementary steps?
        • 1. Re: Need to auto-populate text field with value from radio button
          DC Dowd

          On the Calculate tabe you might enter something like what is below in the custom calculation script

           

          var RB = this.getField("radio_button_name").value;     //Define variable "RB" as the value of your radio button

          if (RB.value !=="Off"){                                               //Execute script only if a radio button choice is unselected

          event.value = RB.value;                                            //Sets value of the text field equal to the value of RB

          }else{                                                                      //If the radio button field is not selected

          event.value = "";                                                       //Text field is empty

          }                                                                             //End of conditional statement

           

          I am somewhat new to scripting, so you may need input from better minds than mine, but this should work. In terms of performing calculations with it, you will need to provide more information for scripters to be able to help out with that one.

          • 2. Re: Need to auto-populate text field with value from radio button
            Thom Parker Adobe Community Professional

            Take a look at the Conditional calculation example file posted on this page:

            http://www.pdfscripting.com/public/47.cfm

             

            Thom Parker
            The source for PDF Scripting Info
            pdfscripting.com

             

            The Acrobat JavaScript Reference, Use it Early and Often

             

            Then most important JavaScript Development tool in Acrobat
            The Console Window (Video tutorial)
            The Console Window(article)