1

I am trying to fill combobox with Javascript but I couldtn be able do it successfuly. This is very simple but I havent worked with Javascript for a long time.

Can anybody help me? here is my code...

<script>
var x = document.getElementById("demo");
var s=""
for(i=1;i<42;i++)
{
    s += '<option value='+i+'>'+points[i].musteri+'</option>';
}
document.getElementById('demo').innerHtml = s;
</script>
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189

2 Answers2

0

Not sure what browser you are using for test but I think you just simply missing ';' after

var s=""

and there is no innerHtml but it is innerHTML attribute for DOM.

This is the JSFiddle I used for test https://jsfiddle.net/ey9b3n2c/3/

0

innerHtml is not a "Select" element property in javascript. You can add "option" like this:

<script>
var x = document.getElementById("demo");
for(i=1;i<42;i++)
{
    var option = document.createElement("option");
    option.text = points[i].musteri;
    option.value = i;
    x.add(option);
}