For some reason I only get to the first option when I alert out below and then it exists my entire function. It never iterates through each option:
function SelectAlbumOption(iAlbumID, iAlbumDropdownID)
{
var dropdownID = '#' + iAlbumDropdownID;
$(dropdownID).each(function(index, currentOption)
{
alert("(currentOption).attr('value'): " + $(currentOption).attr("value"));
if($(currentOption).attr("value") == iAlbumID)
{
alert("matched option");
$(currentOption).attr("selected", "yes");
return false;
}
});
}
right before this function above is called, I add options to that select, so they do exist before this function is called.
Are you leaving critical pieces of the code out? Because you haven’t told us whether you invokeSelectAlbumOptionmultiple times.Your function takes an ID and does an
.eachon 1 element ( unique ID ).Did you mean to do
Or