/ Id-Extras Forum / Duplicating text from one field to another.
August 9, 2021 at 5:43 am #6202warren
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.
August 12, 2021 at 9:14 pm #6444~~Ariel~~Participant
- This topic was modified 9 months ago by ~~Ariel~~.
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.
August 13, 2021 at 1:29 am #6445warren
- This reply was modified 4 weeks ago by ~~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.
WarrenSeptember 3, 2022 at 12:24 pm #6965Olegs KondratjevsParticipant
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.September 4, 2022 at 2:12 am #6969~~Ariel~~Participant
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?September 4, 2022 at 8:23 am #6970Olegs KondratjevsParticipant
Thank you for your reply.
In first field always be ZIP and City
9000 St. Gallen
Second field have to extract from the first field only City
I think ZIP always is 4 digits.September 4, 2022 at 10:09 am #6971~~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 3 weeks, 6 days ago by ~~Ariel~~.