3 Replies Latest reply on Feb 27, 2015 9:26 AM by Sean.twyman

    Check box to copy text from 1 field to another

    Sean.twyman Level 1

      I am trying to use a check box to copy the tech from a billing address text box to a shipping address text box only if the check box is checked.

      I am new to using java and building forms in acrobat so please understand.

       

      I have googled and tried to implement the following script in the shipping address Text field properties under format. but it doesn't work

       

      if (this.getfield('checkbox').value =='Yes'){SHIP_TO.value = Bill_To.value} else {Ship_To.value =""}

       

      thank you for any assistance

        • 1. Re: Check box to copy text from 1 field to another
          gkaiseril MVP & Adobe Community Professional

          Well you cannot use Java within a PDF form. PDF forms use JavaScript which is very different form Java.

           

          Have you opened the JavaScript console for the form and looked to see if there are any errors?

           

          You syntax for the "if' statement is wrong.

           

          The method for obtaining a field object is 'getField" not "getfield".

           

          Field names should be within quotations marks to indicate the item is a text string and not a variable name.

           

          Any time one needs to access a property of a field, like "value", one needs to use the field object for the named field and not the name of the field.

           

          this.getField("Ship_To").value  = ""

          if (this.getField('checkbox').value == 'Yes') {

          this.getField("SHIP_TO").value =  this.getField("Bill_To").value

          }

          • 2. Re: Check box to copy text from 1 field to another
            Sean.twyman Level 1

            Im sorry I mean Java Script.....

            so i put the code:

            this.getField("Ship_To").value  = ""

            if (this.getField('ShipSameBill').value == 'Yes') {

            this.getField("SHIP_TO").value =  this.getField("Bill_To").value

            }

            into the SHIP_TO text box properties, under the format tab (not sure if this is correct)

            then I typed into the BILL_TO text box and then check the checkbox (ShipSameBill) and nothing carried over.

            Am I missing something?

            • 3. Re: Check box to copy text from 1 field to another
              Sean.twyman Level 1

              I made it work. Shat I did is place an action on the check box properties and selected a trigger to run a Java Script.

              Here is the code.

               

              //Set the vars one and two:

                        var one = this.getField("BillingAdd"); //Text Box 1

                        var two = this.getField("ShippingAdd"); //Text Box 2

                        var cb1 = this.getField("ShipSameBill"); // Check Box

               

                        //next check if two is blank and if so, populate it with one’s value

                        if(cb1.value=='Yes'||two.value==null){two.value=one.value}

                          else {two.value=''}