Programmatically create select list

Solution 1:

var arr = [
  {val : 1, text: 'One'},
  {val : 2, text: 'Two'},
  {val : 3, text: 'Three'}
];

var sel = $('<select>').appendTo('body');
$(arr).each(function() {
 sel.append($("<option>").attr('value',this.val).text(this.text));
});

Solution 2:

var s = $('<select/>');
var o = [1, 2, 3];
for (var i in o) {
    s.append($('<option/>').html(o[i]));
}
$('body').append(s);

Solution 3:

I know this is old, but what the hey:

$selectBox.html($.map(myArray, function(){
    return $('<option/>', {text: this});
}));