This guide will show you how to copy the value of a field to another field when clicking a checkbox.
Add this code to Forms → Settings → Custom CSS & JS → Custom JavaScript box:
1 23 4 5678 9 | jQuery(function ($) { $('.quform-field-1_4_1').click(function () { var copy = $(this).is(':checked'); $('.quform-field-1_5').val(copy ? $('.quform-field-1_1').val() : ''); $('.quform-field-1_6').val(copy ? $('.quform-field-1_2').val() : ''); $('.quform-field-1_7').val(copy ? $('.quform-field-1_3').val() : ''); }); }); |
jQuery(function ($) { $('.quform-field-1_4_1').click(function () { var copy = $(this).is(':checked'); $('.quform-field-1_5').val(copy ? $('.quform-field-1_1').val() : ''); $('.quform-field-1_6').val(copy ? $('.quform-field-1_2').val() : ''); $('.quform-field-1_7').val(copy ? $('.quform-field-1_3').val() : ''); }); });
- On line 2 replace
1_4_1
with the unique ID of the checkbox, you can Inspect the checkbox in the browser to get the numbers from the class attribute - On line 5, replace
1_5
with the unique ID of the field you want to copy the value to, and replace1_1
with the unique ID of the field you want to copy the value from - On line 6, replace
1_6
with the unique ID of the field you want to copy the value to, and replace1_2
with the unique ID of the field you want to copy the value from - On line 7, replace
1_7
with the unique ID of the field you want to copy the value to, and replace1_3
with the unique ID of the field you want to copy the value from - Add or remove extra lines as needed