Skip to main content

I have 2 checkboxes on my form. Yes and No. When Yes is checked, a panel is opened. I have a rule to close the panel when No is checked but the Yes box remains checked. How can I remove the check from the Yes box?

 

Yuri

Hi Yuri.  Are you using the New Responsive Designer, Responsive Designer, or Classic Designer?


Classic Designer

You'll have to use JavaScript in a Classic form to accomplish this.  Try adding the code below to the Custom JavaScript section in Form Settings.  Then go to the Control Settings for both Yes/No controls, change the "Store Client ID in JavaScript variable" setting in Advanced to Yes, and add yescheckbox or nocheckbox (respectively) in the "Client ID JavaScript variable name" in each control.  This should uncheck the Yes checkbox if the No checkbox is selected.  You can keep the hide rule on the No checkbox.



 



NWF$(document).ready(function () { 

var checkedno= NWF$("#" + nocheckbox);

checkedno.change(function(){

NWF$('#'+yescheckbox).prop('checked', false)

});

});



NWF$(document).ready(function () {

var checkedyes= NWF$("#" + yescheckbox);

checkedyes.change(function(){

NWF$('#'+nocheckbox).prop('checked', false)

});

});


 


This solution works great. However, I have a new problem.



When I click the Yes button, the panel opens and when I click No, the panel closes. Perfect



But when I click the Yes button again, the panel does not open. I need it to open because I know some user is going to click the wrong box.


I checked my solution on Chrome and Edge, and it's working as expected.  If I click on the Yes checkbox, then the panel displays.  When I click on the No checkbox, the panel hides and the Yes checkbox is unchecked.  Then I check the Yes checkbox again and the panel displays and the No checkbox is unchecked.



 



Some things to check.  Make sure the Yes checkbox is named yescheckbox in the "Client ID JavaScript variable name" setting under Advanced and the No checkbox is named nocheckbox in the "Client ID JavaScript variable name" setting under Advanced.  I also have the form rule on associated to the panel control.  Also make sure the full JavaScript is in the Custom JavaScript section of Form Settings.



 





 





 




bamaeric,

It works perfectly. Thanks for all your help.

I'm using this exact solution but it only works on IE 11, the check box doesn't do anything on Edge or Chrome. Any ideas why it would happen like this?


Hi, I found an issue for my part ! How can I uncheck several checkboxes with only one checkbox on true ?

Reply