*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>');
}
}
}