Friday, May 20, 2016

Hide/Show field on list form based on value from another field SharePoint 2013

<script src="/Shared%20Documents/jquery-1.10.2.min.js"></script> //Edit your correct path
<script src="/Shared%20Documents/sputility.min.js"></script> //Edit your correct path

<script>
// wait for the window to load
$(document).ready(function () {

    var WorskspaceSetupField = SPUtility.GetSPField('WorkspaceSetup');

    var showOrHideField = function() {
        var workspaceSetupFieldValue = WorskspaceSetupField.GetValue();

        if(workspaceSetupFieldValue  == 'No') {
            SPUtility.HideSPField('LaptopSetup');
        }
        else {
            SPUtility.ShowSPField('LaptopSetup');
        }
    };

    // run at startup (for edit form)
    showOrHideField();

    // make sure if the user changes the value we handle it
    $(WorskspaceSetupField.Dropdown).on('change', showOrHideField);
});
</script> 

No comments:

Post a Comment