Copy field contents on button click in adaptive form



Hi all,


I've spent hours going in circles, trying different approaches and I'm just totally stuck. I've created an adaptive form in AEM for forms. I have a hidden text field with a text string value, and I am trying to script a button to select and copy the contents of that text field, when clicked. Then I'd like a message to pop up, confirming the text was copied.


Here's the method I found on W3schools:

var copyText = document.getElementById("textFieldIWantToCopy");;
alert("Copied the text: " + copyText.value);


Absolutely nothing happens when I use this script. I'm still adjusting between LiveCycle Javascript and normal JavaScript, so it could be I just don't have the syntax/terms to do it right, yet.


Does anyone know how to make this work? Thanks so much for your help!

adaptive AEM click copy field form hidden javascript text value

Accepted Solutions (0)

Answers (2)

Answers (2)




@JLNdev  Works for me


Put this on button click:



In Adaptive form go to code editor and place the script. Make sure to replace "guideContainer-rootPanel-basics-basics1-guidetextbox___widget" with correct id for the text field