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

Question

Question

select checkbox when radio button selected

asked on February 21, 2019

I have a form where the user selects departments.  Sometimes they do not consider financial aspects of the related interaction.  I have made a radio field that appears if the Finance checkbox is not selected.  If the user select "Yes", I would like to have the Finance button automatically selected (with any existing values remaining).  

I am not an experienced coder.  Can anyone help?

0 0

Answer

SELECTED ANSWER
replied on February 22, 2019

Hi Mary Lou,

The following Javascript worked for me:

(function() {
  $(document).ready(function() {         
    $('.radio input').change(function() {
      if ($(this).val() == 'Yes') {
        $('input#Field7-0').prop('checked', true);
      }
      else {$('input#Field7-0').prop('checked', false);}
    });
  });
})();

You'll need to apply the "radio" class to your radio button group, like so:

You'll also need to make note of the id associated with the Finance checkbox your checkbox group. The following screenshot walks you through finding this info:

This code will uncheck the box when the radio button is not set to "Yes", but the user will still be able to check the box manually. If you don't want to automatically uncheck this box, just delete line 20.

Best,

Rob

1 0

Replies

replied on February 22, 2019

Thanks.

Worked like a charm!

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

Sign in to reply to this post.