very simple but guess what, not for me. I have a comma separated list like this: Option1,Option2,Option3 that I want to append to a <select> so it becomes <select><option>Option1</option><option>Option2</option><option>Option3</option></select>
I can "split" the list like this (inside a function that gets the list):
var optionsarray = $(this).val().split(',');
$(optionsarray).each(function(i){
var seloption = '<option value="'+optionsarray[i]+'">'+optionsarray[i]+'</option>';
});
But now how do I append seloption to my select list. If I put
$('#selecttoappendto').append('<option value="'+optionsarray[i]+'">'+optionsarray[i]+'</option>');
or
$('#selecttoappendto').append(seloption);
inside the each loop nothing happens. Take it outside the each I can append say optionsarray[0], or optionsarray[1] etc. but I cannot get to append optionsarray[i] which ever way I do it (inside or outside the each). Help please - thanks in advance