I have a select, and I am filling the options using javascript. Something like
var select = document.getElementById(\"selectBox\");
for (var i = 0;
You can try this
Javascript
var select = document.getElementById("selectBox"),
data = [{ name: "y", id: "b" }, { name: "z", id: "c" }],
i;
for (i = 0; i < data.length; i += 1) {
var option = document.createElement("option");
option.appendChild(document.createTextNode(data[i].name));
// or alternately
//option.text = data[i].name;
option.value = data[i].id;
select.appendChild(option);
}
On jsfiddle
And of course there is the standards compliant method HTMLOptionElement.Option() as described by @MaxArt