Hide/Show Fields

Hello

I am just trying our Plumsail Forms for Sharepoint Online.

I have managed to use the following Javascript to show/hide a field depending on if another field is True/False

fd.spRendered(function() {

function hideOrShowDateofBirth() {
if (fd.field('Under25_x003f_').value === true) {
$(fd.field('DateofBirth').$parent.$el).show();
} else {
$(fd.field('DateofBirth').$parent.$el).hide();
}
}
fd.field('Under25_x003f_').$on('change',hideOrShowDateofBirth);
hideOrShowDateofBirth();
});

However I have a further True/False field where I want to show/hide a DataTable Control and am struggling. I have tried the following Javascript

fd.spRendered(function() {
function hideOrShowConvictionsTable() {
if (fd.field('ConvictionsQuestion').value === true) {
$(fd.control('ConvictionsTable').$parent.$el).show();
} else {
$(fd.control('ConvictionsTable').$parent.$el).hide();
}
}
});

Anyone got any ideas what I have done wrong.

TIA

Stuart

Hello @Stuart_Fairbairn,

To hide/show the 'List or Library' control, please use the following code.

$(fd.control("SPDataTable0").$el).hide();

$(fd.control("SPDataTable0").$el).show();

So your code should be as below

fd.spRendered(function() {
    function hideOrShowConvictionsTable() {
        if (fd.field('ConvictionsQuestion').value === true) {
            $(fd.control("ConvictionsTable").$el).show();
        } else {
            $(fd.control("ConvictionsTable").$el).hide();
            }
    }

    fd.field('ConvictionsQuestion').$on('change',hideOrShowConvictionsTable);

    hideOrShowConvictionsTable();
});
1 Like

Thank you so much for your help - that worked :slight_smile:

Stuart

1 Like