cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
christinagatele
Nintex Newbie

Set Checkboxes to Yes based on two conditions

Jump to solution

Hi,

In my form I would like to set a series of checkboxes to yes depending on the value of two other choice fields: Applicable Gate and Type of Work.

For instance, in the screenshot below, if a person selects '8Q' then 'Emergent' then I would like the checkboxes in the table below to auto populate:

I would prefer to do this via JavaScript as there are a lot of tables and therefore a lot of checkboxes, but happy to do this another way if there are other solutions.

Please can anyone help me to do this?

Thank you  

Christina.

Labels: (2)
0 Kudos
Reply
6 Replies
Automation Master
Automation Master

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

it might look like this

NWF.FormFiller.Events.RegisterAfterReady(function () {
   NWF$('#'+jsvarApplicableGate).change(HandleSelectionChange);
   NWF$('#'+jsvarTypeOfWork).change(HandleSelectionChange);
});


function HandleSelectionChange(){
  var applicableGateVal = NWF$('#'+jsvarApplicableGate + ' input:checked').val();
  var typeOfWorkVal = NWF$('#'+jsvarTypeOfWork + ' input:checked').val();
  if(applicableGateVal === "8Q" && typeOfWorkVal === "Emergent"){
     NWF$('.ApplicableTickBoxClass input').prop('checked',true);
  } 
}

0 Kudos
Reply
christinagatele
Nintex Newbie

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

Thank you for this.

I have a very basic knowledge of javascript so just trying to understand which bit I change in order to include the checkbox.  Would that the text I've underlined in red?

0 Kudos
Reply
Automation Master
Automation Master

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

you have to configure javascript variable 'jsvarApplicableGate' for 'Applicable Gate' radio control and variable 'jsvarTypeOfWork' for 'Type of Work' radio control.

next you have to configure CSS class 'ApplicableTickBoxClass' on each of checkboxes you want to get ticked based on seleceted above radios

0 Kudos
Reply
christinagatele
Nintex Newbie

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

Brilliant!  That worked.  I just needed to add the CSS class to the checkboxes.

My next query is... if I change my mind and select 'Waiver' after 'Emergent' the checkboxes remain checked.  What would I need to do to remove the result if the initiator changes their mind or selects the wrong radio control?

Thank you!

0 Kudos
Reply
Automation Master
Automation Master

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

simply

function HandleSelectionChange(){
  var applicableGateVal = NWF$('#'+jsvarApplicableGate + ' input:checked').val();
  var typeOfWorkVal = NWF$('#'+jsvarTypeOfWork + ' input:checked').val();
  if(applicableGateVal === "8Q" && typeOfWorkVal === "Emergent"){
     NWF$('.ApplicableTickBoxClass input').prop('checked',true);
  } else {
     NWF$('.ApplicableTickBoxClass input').prop('checked',false);
  }
}
0 Kudos
Reply
christinagatele
Nintex Newbie

Re: Set Checkboxes to Yes based on two conditions

Jump to solution

You absolute genius!  Thank you!

Reply