You are viewing limited content. For full access, please sign in.

Question

Question

Ask the Expert Panel Question

asked on May 21

A question came up on today's Champion Webinar to move the values of a Radio Button or Checkbox field to another Radio Button or Checkbox field later in the form.  Here is the JS for Modern Designer to do this:

LFForm.onFieldChange(function() {
  var value = LFForm.getFieldValues({ fieldId: YOUR FIELD ID });
  LFForm.setFieldValues({ fieldId: YOUR FIELD ID RECEIVING VALUE }, value);
}, { fieldId: YOUR FIELD ID });

If you want to make the second field Read Only to force a match you can either use Show/Hide fields to disable the field when its not blank or use this script:

LFForm.onFieldChange(function() {
  var value = LFForm.getFieldValues({ fieldId: YOUR FIELD ID });
  LFForm.enableFields({ fieldId: YOUR FIELD ID RECEIVING VALUE }).then(function() {
    LFForm.setFieldValues({ fieldId: YOUR FIELD ID RECEIVING VALUE  }, value).then(function() {
      LFForm.disableFields({ fieldId: YOUR FIELD ID RECEIVING VALUE  });
    });
  });
}, { fieldId: YOUR FIELD ID });

 

8 0

Answer

SELECTED ANSWER
replied on May 21

Here is the script for Classic.  You can make the receiving field read only from the field options in Classic.
 

$(document).ready(function() {
  $('input[name="FieldID"]').on('change', function() {
    var value = $(this).val();
    $('input[name="FieldID"][value="' + value + '"]').prop('checked', true);
  });
});

 

3 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.