iam creating dynamic dropdown with onchange event. how i get dropdown id on onchange function
What I have tried:
function addSelect(divname, columname, dropid, tablename,pd) {
var newDiv = document.createElement(pd);
var change = "dropchange(" + dropid + ")";
var html = '<select id="' + dropid + '" >'
var obj = {};
obj.coluname = columname;
obj.tablename = tablename;
$.ajax({
url: "webmethod.aspx/dropdownbine",
data: JSON.stringify(obj),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function(r) {
var result = r.d;
var sel = "SELECT"
html += "<option Value='" + sel + "'>" + sel + "</option>";
for (i = 0; i < result.length; i++)
html += "<option value='" + result[i] + "'>" + result[i] + "</option>";
html += '</select>';
newDiv.innerHTML = html;
document.getElementById(divname).appendChild(newDiv);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('Got an Error Dropdownlist bind ');
}
});
}
function dropchange(id) {
alert(id.value);
}