Page 1 of 1

Condition based on multiple choise option

Posted: 12 Jul 2018
by Katy
Hi
I am trying to set up the condition which will show/hide some accordion tabs based on what check boxes are checked in multiple choice field. here is my code for one:

Code: Select all

function setIFS() {
	var checkboxIndex = 1;
    fd.field('FinanceSys').control()._el().find('input[type="checkbox"]').eq(checkboxIndex).is(':checked');
  if (checkboxIndex != null) {
 
$('#fd_accordion-0 > h3').eq(0).show();
$('#fd_accordion-0 > div').eq(0).show();
  } else {
$('#fd_accordion-0 > h3').eq(0).hide();
$('#fd_accordion-0 > div').eq(0).hide();
  }
}
 
fd.field('FinanceSys').change(setIFS);
 
setIFS();
The idea is if 1st check box is chosen then IFS accordion tab will be shown. But it is not working.... Please help me with setting this condition.

Re: Condition based on multiple choise option

Posted: 12 Jul 2018
by Nikita Kurguzov
Dear Katy,
Why not use our JavaScript API to retrieve values from choice field with checkboxes?

A condition like this should do:

Code: Select all

if(fd.field('Checkboxes').value().indexOf(0) >= 0) {
  //first option selected
}
else {
  //first option not selected
}

Re: Condition based on multiple choise option

Posted: 13 Jul 2018
by Katy
That works! Thank you, Nikita!