Question: I have a select, and I am filling the options using javascript. Something like

```
    var select = document.getElementById("selectBox");

    for (var i = 0; i < data.length; i++) {
        var option = document.createElement("option");
        option.innerHTML = data[i].name;
        option.value = data[i].id;
        select.appendChild(option);
    }

```

It works fine on Firefox and Chrome, but not on Internet Explorer. When I check the html generated on IE I see 

```
    <select id="selectBox"/>

```

Is there something I can do for it to work on IE?

**EDIT** 
After refreshing the html page on development tools(IE doesn't do this after the html change) I see that the options have been added, but there seems to be a problem assigning the value, I'm using

```
select.value = theValue;

```

Answer: 
Use `add` instead of `appendChild`:

```
select.add(option);

```

Also, using the `Option` constructor can save you some lines of code:

```
var option = new Option(data[i].name, data[i].id);

```
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](http://jsfiddle.net/Xotic750/ZABGw/)

And of course there is the standards compliant method [`HTMLOptionElement.Option()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement.Option) as described by @MaxArt