Copying data from one field to another

The Quform WordPress v2 documentation is not yet finished. Please post on the forums if you have any questions in the mean time.

Click here to visit the complete documentation for Quform 1.x

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(document).ready(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(document).ready(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 replace 1_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 replace 1_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 replace 1_3 with the unique ID of the field you want to copy the value from
  • Add or remove extra lines as needed

See also

Still having trouble? Head over to the forums.

Forums