Probably the simplest answer here is to use the Option
constructor rather than setting the HTML of the select
element.
var form = document.createElement('form');
var select = document.createElement('select');
select.id = "dropdown_options";
select.options.add(new Option("Some text"));
for (/*...whatever your loop is...*/) {
select.options.add(new Option("text of the option", "optional value of the option"));
}
form.appendChild(select);
$("size_list").appendChild(form);
Note that you use add
(rather than push
) with the options collection (it's not an array; some implementations have push
, but add
is more reliable).