Show/Hide Field based on Checkbox Selection

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
enillrae
Posts: 17
Joined: Mon May 29, 2017

16 Oct 2019

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();

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

17 Oct 2019

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 2958 times
And make sure that CSS assigned properly.
CSS.PNG
CSS.PNG (3.78 KiB) Viewed 2958 times
If you have any errors in the console (F12), please send the screenshot.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests