0

*UPDATE I found the fix. Needed to add a t to the "#ClaimtStatusSelected".

(Original problem) I am working on a project where a user will choose from 5 choices. If they pick a specific choice (LOB), for example DS only, then the items with only DS should be available. So if a user chooses the WC choice, the items that are for the DS only, should not show up. Here is the code i have so far and what is does. If you pick your item before you pick your LOB, so a DS Only option, and click WC, It will prompt the user and tell them their choice will be deleted.

(NEW PROBLEM) When selecting the LOB the ones that aren't specific are deleted as intended. However when i click on the LOB that is needed, the choices in the dropdown list appear at the bottom. How do I get them to show up in the correct alphabetical order?

function ValidateClaimStatusValues(selectedLOBs, thisDiv) {
    var listItems = $("#s2id_ClaimtStatusSelected ul li");

    listItems.each(function () {
        var thisLI = $(this)[0];

        if (thisLI.innerHTML.indexOf("(DS Only)") >= 0 &&
            selectedLOBs.indexOf("DS") < 0) {

            ShowMessage("Selecting this Line of Business will cause one or more of your selected condition values to be removed.",
                "Warning",
                false,
                true,
                function () {
                    $(thisLI).children('a').click();
                },
                "OK",
                "Cancel",
                function () {
                    selectedLOBs += ",DS";
                    thisDiv.addClass("lobSelected");
                    thisDiv.removeClass("noselect");
                    $("#" + thisDiv.attr("associatedcheckbox"))[0].checked = true;
                });
        }
    });
    var dropdownItems = $("#ClaimtStatusSelected").children();
    if (selectedLOBs.indexOf("DS") < 0) {
        dropdownItems.each(function () {
            if ($(this)[0].value == "R") {
                $("#ClaimtStatusSelected option[value='R']").remove();
            }
            else if ($(this)[0].value == "J") {
                $("#ClaimtStatusSelected option[value='J']").remove();
            }
            else if ($(this)[0].value == "S") {
                $("#ClaimtStatusSelected option[value='S']").remove();
            }
        });
    }
    else {
        var foundDisabilityOnlyCondition = false;
        dropdownItems.each(function () {
            if ($(this)[0].value == "R") {
                foundDisabilityOnlyCondition = true;
            }
            else if ($(this)[0].value == "J") {
                foundDisabilityOnlyCondition = true;
            }
            else if ($(this)[0].value == "S") {
                foundDisabilityOnlyCondition = true;
            }
        });

        if (!foundDisabilityOnlyCondition) {
            $("#ClaimtStatusSelected").append(
                '<option value="R">Reinstated (DS Only)</option>');
        }
        if (!foundDisabilityOnlyCondition) {
            $("#ClaimtStatusSelected").append(
                '<option value="J">JURIS Admin (DS Only)</option>');
        }
        if (!foundDisabilityOnlyCondition) {
            $("#ClaimtStatusSelected").append(
                '<option value="S">Suspended (DS Only)</option>');
        }
    }
}
spatel
  • 21
  • 9
  • Is that asp.net mvc, or webform...? My point is you can use back-end to control the dropdownlist – Jacky Oct 20 '16 at 19:51
  • this question has nothing to do with .net or c#. you will get better responses if you tag your questions correctly. – I wrestled a bear once. Oct 20 '16 at 19:56
  • You can implement a cascading drop down list and attach the onChange event to control that drives the options in the drop down list. This link shows how to implement cascade drop down list using jQuery: http://stackoverflow.com/questions/18351921/how-to-populate-a-cascading-dropdown-with-jquery – Sparrow Oct 20 '16 at 20:30
  • @Pamblam Jacky & Feryal Badili. Solved my first issue, thanks for the help! – spatel Oct 20 '16 at 21:06

0 Answers0