Script to copy one field into another in Adobe Designer | Adobe Higher Education
Skip to main content
April 11, 2024
Beantwoord

Script to copy one field into another in Adobe Designer

  • April 11, 2024
  • 2 reacties
  • 862 Bekeken

Hi,

 

 

 

I am trying to use a script to copy one field "Title" to another field "Title2" whenever someone types into "Title", otherwise if "Title" is empty they can still enter something in "Title2". I've checked the forums and tried to make something work such as an event.value = get Field script but I'm not having any luck. Seems no matter what i enter for a script, it doesnt execute in the final document. Anyone have insight?

Er kunnen geen reacties meer worden geplaatst op dit onderwerp.
Beste antwoord door arunpatidar

Hi @anthonyva2 

We kindly suggest checking your query on the dedicated Adobe designer community. You're likely to receive faster and more relevant responses there. You can access the community at the following link: Adobe Designer Community

2 reacties

April 11, 2024

Hey @anthonyva2  You can try this, it will work. 

 

document.addEventListener("DOMContentLoaded", function() {
var titleField = document.querySelector("[name='./title']"); // Adjust the selector as per your field's name or ID
var title2Field = document.querySelector("[name='./title2']"); // Adjust the selector as per your field's name or ID

// Copy value from Title to Title2 as the user types in Title
titleField.addEventListener("input", function() {
if(titleField.value) {
title2Field.value = titleField.value;
}
});

// Optional: Clear Title2 if Title is cleared and Title2 has not been manually edited
titleField.addEventListener("blur", function() {
if(!titleField.value && title2Field.value === titleField.value) {
title2Field.value = '';
}
});
});

 

 

Good luck. 

April 11, 2024

Thank you for replying! Unfortunately this did not work for me. It returns an error of "document not defined" in the acrobat debugger console. 

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAntwoord
Community Advisor
April 12, 2024

Hi @anthonyva2 

We kindly suggest checking your query on the dedicated Adobe designer community. You're likely to receive faster and more relevant responses there. You can access the community at the following link: Adobe Designer Community

Arun Patidar