'Shipping address data to be same as billing address

I have a billing address and shipping address fields. The shipping address fields are hidden unless a user clicks on a checkbox (stimulus) indicating "shipping address same as billing address?"

Using rails, how might one go about copying the text from the billing address to the shipping address when the checkbox is clicked? Ideally allowing this text to still be editable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source