Expand my Community achievements bar.

SOLVED

Script to copy one field into another in Adobe Designer

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

3 Replies

Avatar

Level 1

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. 

Avatar

Level 1

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

Avatar

Correct answer by
Community Advisor

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