Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Create a component to copy One component node to another component node

Avatar

Level 4

Hi Team

 

I am working aem forms using form container and default form components.(not adaptive forms)

 

My requirement is to create a form component (copy content) where I will provide ids in source and destination fields and expected to perform copy value of source node to destination node based on id. 

 

pras78022281_1-1681126612445.png

 

Under Source and Destination fields I will provide ids of another text components and it should take its value and assign. 

Example: 

document.getElementById('new-building-name-section').value = document.getElementById('building-name-section').value;

 

My requirement is like I will have set of fields like permanent address, when a checkbox is selected those fields should be copied to new address fields like delivery address. 

 

Content Author should have flexibility to author on dialog which fields should be copied from where to where. 

 

Any pointers or ideas will be very helpful for me

 

Thanks and Regards

Prashanthi 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @Prashardan ,

you can set ID in your text field by granite:id property.

Sady_Rifat_1-1681130306862.png

Add a checkbox for copying the element value consent and set an event listener for the checkbox.

$(document).on("change"


Then by jQuery you can easily set the value for the destination field.

Sady_Rifat_0-1681130290610.png

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hello @Prashardan ,

you can set ID in your text field by granite:id property.

Sady_Rifat_1-1681130306862.png

Add a checkbox for copying the element value consent and set an event listener for the checkbox.

$(document).on("change"


Then by jQuery you can easily set the value for the destination field.

Sady_Rifat_0-1681130290610.png