Reputation: 419
var el_s = document.createElement('select');
for(var i=1;i<32;i++)
{
var j = i;
j = document.createElement('option');
j.text=i;
el_s.appendChild(j);
}
table.appendChild(el_s);
i have to generate dynamically select tag and onchange method how to implement onchange function in select tag so that i get the selected value from the dropdown
Upvotes: 3
Views: 1204
Reputation: 308
var el_s = document.createElement('select');
for(var i=1;i<32;i++)
{
var j = i;
j = document.createElement('option');
j.text=i;
el_s.appendChild(j);
}
$(el_s).change(function(){
//your function code
alert("hi");
});
table.appendChild(el_s);
Upvotes: 1
Reputation: 104775
How about:
el_s.onchange = function() {
alert("jey");
}
Demo: http://jsfiddle.net/tymeJV/kyfnc/
Upvotes: 4