Page 1 of 1

Show/Hide Field based on Checkbox Selection

Posted: 16 Oct 2019
by enillrae
Hi,

I have a multichoice checkbox and another field. I want to be able to show or hide the field if the first item in the checkbox list is selected. I've done the following code but it's not working. Please advise.

function setSafetyImpact(){
var checkboxIndex=0;
if(fd.field('EventImpact').control()._el().find('input[type="checkbox"]').eq(checkboxIndex).is(':checked')){
//show field
$('.safety-impact').show();
}else{
//hide field
$('.safety-impact').hide();
}
}

fd.field('EventImpact').change(setSafetyImpact);

setSafetyImpact();

Re: Show/Hide Field based on Checkbox Selection

Posted: 17 Oct 2019
by mnikitina
Hello enillrae,

The code is correct. It works in my form.

Please check that the internal name of the field in the code is correct.
internalName.PNG
internalName.PNG (3.45 KiB) Viewed 2966 times
And make sure that CSS assigned properly.
CSS.PNG
CSS.PNG (3.78 KiB) Viewed 2966 times
If you have any errors in the console (F12), please send the screenshot.