[Resolved] copy field value to another field if checkbox checked
This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I would like to copy the first field value into the second field when the checkbox is checked and before submitting the form. I have used the below code in JS of the user form.
function copyTextValue() {
if(document.querySelector("input[name='wpcf-agree']").checked){
var email = document.querySelector("input[name='user_email']").value;
document.querySelector("input[name='nickname']").value; = email;
}
}
we have tested the code it was working fine outside WordPress, but it is not working when I used it here. What is wrong with it??
Onclick is not a valid attribute for our Toolset Forms shortcodes. In order to implement your solution the best way is to trigger the jQuery trigger. See details below.