I have this
var selected = []
$('#SelectBoxContainer .DDLs :selected').each(function (i, selected)
{
alert($(selected).val());
selected[i] = $(selected).val();
});
My alert is telling me that it is going through this loop and getting the select box values. Yet once everything is said and done there is nothing in my “selected” array.
Your callback defines a local variable named
selected, which hides theselectedvariable in the outer scope. Theselectedinselected[i] =is theselectedfromfunction (i, selected), not theselectedfromvar selected.Rename one of the two variables for this to work.