I am trying to create a drop down list of users on a website and, if those users are past their subscription date, they're red in the drop down list. This works fine.
function SetDropDownColors(itemArray, dropDownList) { $('#' + dropDownList).each(function () {
for (var id in itemArray) {
//should the user be found in the retired array, make them red so they cannot be selected by the admin
if ($.inArray(itemArray[id].Value, retiredUsers[0]) >= 0) {
$("option[value=" + "'" + itemArray[id].Value + "'" + "]").css({ 'font-style': 'italic', 'color': 'red' });
}
}
});
}
However, when the admin selects a user that's expired, the text turns back to black and the font to normal (instead of italic).
Why does that happen, and how can I change it to be what it was prior to being selected?
I've tried many things, but here is the latest; several drop downs have the actionCreator
class, so I key off the event. someFuntion
returns bool and the console has the 'hit', so I know it makes it that far.
I can get everything to turn red/italic by making $(this).css
red and italic but that isn't what's needed. Not every user should appear red, if they have a good subscription they should appear black in the drop down list.
Now, moving to the selected option, I have hit part:
function setSelectedValueColors() {
$('.wds-red').each(function (index, value) {
var person = $(this).val();
var selectValue;
if (person) {
selectValue = person.trim();
}
if ($.inArray(selectValue, retiredUsers[0]) >= 0) {
console.log('I think this should be red: ', selectValue)
$(this).css('font-style', 'italic');
$(this).css('color', 'red');
$(this).children().css('font-style', 'normal');
}
else {
console.log('I think this should be black: ', selectValue)
$(this).css('font-style', 'normal');
$(this).css('color', 'black');
$(this).children().css('font-style', 'normal');
}
});
}
This will not retain and make the text red for ONLY the selected value; all values in the drop down list appear red.
I've revised this question to my revised approach.
Any help is greatly appreciated.
Thanks,
B