1

I have 2 drop-down column in SharePoint 2010 lists in the first column I have 2 values Region and Country and in the second column I have again 2 values such GDC and Country. Now after page loading I just want to get the second drop-down value GDC on clicking Region in the first drop-down.Below is the code snippet where I am successfully hide the second column on clicking the value in first drop-down.

​<script src="/teams/GISS/SiteAssets/js/jquery-1.12.3.min.js"></script>    
<script src="/teams/GISS/SiteAssets/js/sputility.min.js"></script>
<script>

// wait for the window to load
$(document).ready(function () {
    // Get a single select dropdown field
    var ProjectField = SPUtility.GetSPField('Project Level');
    var CountryField = SPUtility.GetSPField('Country');
    // create a function to show or hide City based on Country's value
    var showOrHideField = function() {
        var ProjectFieldValue = ProjectField.GetValue();
        var CountryFieldValue = CountryField.GetValue();
        // Hide the City field if the selected value is Other
        if(ProjectFieldValue === 'Country') {
            CountryFieldValue = 'GDC';
            SPUtility.HideSPField('Country');
        }
        else {
            SPUtility.ShowSPField('Country');
        }
    };

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

    // make sure if the user changes the value we handle it
    $(ProjectField.Dropdown).on('change', showOrHideField);
});
</script>  
  • Hi requesting please provide some suggestion.. Thanks – Barun Ghatak Dec 6 '16 at 12:01

Your Answer

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

Browse other questions tagged or ask your own question.