selectBox1 = document.createElement("select");
selectBox2 = document.createElement("select");
selectBox1.setAttribute("id","select1");
selectBox2.setAttribute("id","select2");
tr = document.createElement('tr');
for(var k = 1; k<headers.length; k++){
var op = new Option();
var op1 = new Option();
op.value = op1.value= headers[k];
op.text = op1.text = headers[k];
selectBox1.options.add(op);
selectBox2.options.add(op);
th = document.createElement('th');
th.appendChild(document.createTextNode(headers[k]));
tr.appendChild(th);
}
document.getElementById("table").appendChild(selectBox1);
document.getElementById("table").appendChild(selectBox2);
When I use op object and insert the option in the 1st and 2nd select box, only the 2nd select box is populated and 1st one is empty. I've to take two option objects. Why is that so? It's not a problem but I want to understand why it's happening.

op1for here?op1try adding that as option DEMO