Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Copy field contents on button click in adaptive form

Avatar

Avatar
Give Back
Level 1
JLNdev
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Give Back
Level 1
JLNdev
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 1
Validate 1
Boost 1
Applaud 5
View profile
JLNdev
Level 1

15-09-2020

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");
copyText.select();
document.execCommand("copy");
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 (1)

Accepted Solutions (1)

Avatar

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile
workflowuser
Employee

15-09-2020

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile
Mayank_Gandhi
Level 10

17-09-2020

@JLNdev  Works for me

 

Put this on button click:

document.getElementById("guideContainer-rootPanel-basics-basics1-guidetextbox___widget").select();
document.execCommand("copy");
alert("copied");

 

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