2

With the following code I am able to hide a normal lookup column based on drop down, But multi select I am not being able to

In multi select the identifier is SelectCanditate;SelectResult

Should I provide it together or as two separate variable.

function hideWorkgroupControl() {
        var control = getTagFromIdentifierAndTitle("select", "SelectCandidate", "Workgroup");

      //  var control = getTagFromIdentifierAndTitle("select", "SelectResult", "Personnel");
           control.parentNode.parentNode.parentNode.style.display = "none";

        //add an onchange event to the dropdown
        getTagFromIdentifierAndTitle("select", "DropDownChoice", "Types").onchange = function () { ChangeEvent() };


    }


    function ChangeEvent() {

        //get the dropdown
        var dropDown = getTagFromIdentifierAndTitle("select", "DropDownChoice", "Types");

        //get the selected value
        var option = dropDown.options[dropDown.selectedIndex].text;

        //get the control
        var control = getTagFromIdentifierAndTitle("select", "SelectCandidate", "Workgroup");

        //show hide based  on your condition
        if (option == "Workgroup") {
            control.parentNode.parentNode.parentNode.style.display = "";
        }
        else {
            control.parentNode.parentNode.parentNode.style.display = "none";
        }

    } 

    //this gets the field based on title identifier and tagname
    function getTagFromIdentifierAndTitle(tagName, identifier, title) {
        var len = identifier.length;
        var tags = document.getElementsByTagName(tagName);
        for (var i = 0; i < tags.length; i++) {
            var tempString = tags[i].id;
            if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
                return tags[i];
            }
        }
        return null;
    }

1 Answer 1

0
function updateDropDownsforTask() {
    var dropdown = $("select[Title='Types']");
    if (dropdown.length != 0) {
        //$("select[Title='Workgroup']").parent().parent().parent().parent().hide();
        $("select[title='Workgroup selected values']").parent().parent().parent().hide();
        //$("input[Title='ReroutedUser']").parent().parent().parent().parent().hide();
        var dropdownid = dropdown[0].id;

        $('#' + dropdownid).change(function () {
            onChangeDropDown(dropdownid);
        });
    }
}

function onChangeDropDown(dropdownid) {
    var currentvalue = $('#' + dropdownid + ' :selected').text();
    var userdropdown = $("select[title='Workgroup selected values']");
    if (userdropdown.length == 0) {
        userdropdown = $("input[Title='Workgroup']");

        if (currentvalue == 'Workgroup') {
            userdropdown.parent().parent().parent().parent().show();
        }
        else {
            userdropdown.parent().parent().parent().parent().hide();
        }
    }
    else {

   if (currentvalue == 'Workgroup') {
       userdropdown.parent().parent().parent().show();

       //$("select[Title='ReroutedUser']").parent().parent().parent().show();
   }
   else {
       userdropdown.parent().parent().parent().hide();
   }

}

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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