1

I found another thread here with exactly what I'd like to do: Hide a field based on the value of another field. If WorkspaceSetup= NO, LaptopSetup field is hidden. The other thread is here (I can't comment because I don't have enough reputation points yet)

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

I can't seem to get this to work. I'm also a little confused on what the 2nd commenter means as far as the on.change event. This is how I changed the code to reflect my fields:

enter image description here

1

Make sure below point before using SPUtility.js.

It currently will NOT work with:

  • External list forms
  • Forms that have been customized using Infopath
  • Sites with Minimal Download Strategy enabled (feature resides in Manage Site features)

Try below code:

<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> 
  • Thank you, Dikesh. I do have this on an InfoPath for so I guess that explains why it will not work. At least I know that now. I appreciate the info. – markasey May 20 '16 at 16:23
  • If this is helpful then please mark my answer and upvote as well :) – Dikesh Gandhi May 21 '16 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.