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

  • Author
  • #6202 Reply
    warren

      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.

      • This topic was modified 1 year, 1 month ago by ~~Ariel~~.
      #6444 Reply
      ~~Ariel~~
      Participant

        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.

        HTH,
        Ariel

        • This reply was modified 5 months, 1 week ago by ~~Ariel~~.
        #6445 Reply
        warren

          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.

          Cheers

          Warren

          #6965 Reply
          Olegs Kondratjevs
          Participant

            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
            ~~Ariel~~
            Participant

              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
              Participant

                Hi Ariel,

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

                #6971 Reply
                ~~Ariel~~
                Participant

                  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.

                  • This reply was modified 5 months, 1 week ago by ~~Ariel~~.
                Viewing 7 posts - 1 through 7 (of 7 total)

                Tagged: 

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