Jump to content

Auto check the Check box depending of the value of the dropdown


Recommended Posts

To implement such a workflow you need to add Header/Footer and insert this little snippet of code into the footer. Note that "HTML Editor" needs to be disabled.

 

<script>

   document.getElementById('cbParamVirtual1').addEventListener("change", function() {
      if (document.getElementById('cbParamVirtual1').value == 'Choice_1') {
         document.getElementById('cbParamVirtual20').checked = true;
      } else if (document.getElementById('cbParamVirtual1').value == 'Choice_2' || document.getElementById('cbParamVirtual1').value == 'Choice_3') {
         document.getElementById('cbParamVirtual21').checked= true;
      } else {
         document.getElementById('cbParamVirtual20').checked = false;
         document.getElementById('cbParamVirtual21').checked = false;
      }
   });

</script>

You need to choose your own ID values of elements using Developer tools of a browser.
Also, you need to adjust the values of Dropdown in the code according to your adjustments in the Dropdown.

This code can be adjusted depending on the amount of the choices if the Dropdown and CheckBox.

 

<script>

   document.getElementById('cbParamVirtual1').addEventListener("change", function() {
      if (document.getElementById('cbParamVirtual1').value == 'Choice_1') {
         document.getElementById('cbParamVirtual20').checked = true;
      } else if (document.getElementById('cbParamVirtual1').value == 'Choice_2' || document.getElementById('cbParamVirtual1').value == 'Choice_3') {
         document.getElementById('cbParamVirtual21').checked= true;
      } else if (document.getElementById('cbParamVirtual3').value == 'Choice_3' || ... || document.getElementById('cbParamVirtualX').value == 'Choice_X') {
         document.getElementById('cbParamVirtualX').checked= true;
      } else {
         document.getElementById('cbParamVirtual20').checked = false;
         document.getElementById('cbParamVirtual21').checked = false;
         .
         .
         .
         document.getElementById('cbParamVirtual2X').checked = false;
      }
   });

</script>

 

 

 

11.JPG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...