/ Id-Extras Forum / Duplicating text from one field to another.

  • Author
  • #6202 Reply

      I want to duplicate text from one field to another. I know that the simple way is to give both fields the same name, but I want to make one of the fields turn off and on as it is on a popup window with 5 popups layered over each other. I cannot do this if both fields have the same name as they will both be visible or both hidden.

      I am turning the fields on each layered popup off when not selected so that the completed fields do not show through the other layers. But I want the first field to stay visable when the second is hidden.

      #6444 Reply

        Hi Warren,

        I’m also not managing to use the “same field name” trick (which is not to say it is not possible – you may want to ask on the Adobe Acrobat forum, an expert there may have a solution).
        So what I would do in this case is a one-line custom “format” script that copies the contents of Field A to Field B whenever Field A is modified. It looks like this:
        this.getField("Field B").value = this.getField("Field A").value;
        This script would be attached to Field A. In FormMaker in InDesign open the “Format” tab and choose “Custom” from the dropdown, and paste this in. Obviously you would need to change the field names to match the particulars of your form.


        #6445 Reply

          Thanks Ariel.

          This you think would be a standard step in In Design, I guessed it would be one line of code, and I was trying to figure it out with my limited coding skills.

          Many thanks.



          #6965 Reply
          Olegs Kondratjevs

            Hi Ariel,

            Can you help me, please.
            Is it possible to get only a part of the fields text?
            In first field I have a ZIP number and City (8006 Zürich)
            I need the second field to get only City from the first field.

            #6969 Reply

              Hi Olegs,
              Yes, it should be possible.
              Could you post several examples of the text as it appears, and the text as you would like it to appear after it is extracted?

              #6970 Reply
              Olegs Kondratjevs

                Hi Ariel,

                Thank you for your reply.
                In first field always be ZIP and City
                8006 Zürich
                9000 St. Gallen
                9642 Ebnat-Kappel
                8057 Zürich
                Second field have to extract from the first field only City
                St. Gallen
                I think ZIP always is 4 digits.

                #6971 Reply

                  I think something like this should work (not tested):

                  this.getField("Field B").value = this.getField("Field A").value.replace(/^[\d ]+/, "");

                  … which should just delete any digits and/or regular spaces at the beginning of the string.

                Viewing 7 posts - 1 through 7 (of 7 total)


                Reply To: Duplicating text from one field to another.
                Your information: