Forums

Copying field input to other fields

itsjeff 01 Feb, 2017
Hello, I am trying to improve a form's usability by copying & hiding a section of address input fields if the user indicates they want to use the same address from another section. It's basically the common task of reusing the billing address for shipping.

In fact, I found and tried to use the example you provided in the FAQ: https://www.chronoengine.com/faqs/58-cfv4/cfv4-elements-and-html/2690-how-can-i-automatically-copy-fields-from-one-part-of-my-form-to-another.html

However, I don't know what's going wrong. When I click the button, it just resets/clears the field input in the initial set. No change to the second set. It just wipes out the data and they show the placeholders again.

I have tried numerous adjustments. I had been using fieldset containers rather than custom or divs, or did not have them split up explicitly as the demo explained. I had hoped to use a checkbox instead of a button, to use the "events" tab to hide the section if selected. Eventually, I wiped out any differences and created that setup as described. It yielded the same results.

If you could please advise or suggest anything to troubleshoot I would really appreciate it, as I'm stuck with no ideas. Here is the form I've been building if that helps!

Thank you,
Jeff
GreyHead 01 Feb, 2017
Answer
Hi Jeff,

I think that the code is copying 'billing address' to 'delivery address' and in your case it needs to be the other way around.

Bob
itsjeff 01 Feb, 2017
Of course it is.. I tested that earlier thinking I may have had them reversed, but it didn't copy anything or empty the fields. Now it is definitely working in the reverse way. I should be able to adapt it from there. If not, I'll check back tomorrow! Thanks.
itsjeff 02 Feb, 2017
1 Likes
Sure enough, that's what it was. I must have corrected everything but the source / destination names.

Once that was sorted, I was relatively easily able to figure out using a checkbox instead of a button, too. Thanks.
This topic is locked and no more replies can be posted.