iam binding the dropdown using ajax. iam set default value on dropdown bind useing selected event. if dropdown complete the bind. i want to get selected value on default. and iam change another dropdown to use of this default value on page load
thanks Regards
What I have tried:
function addSelect(divname, columname, defaultvalue,dropid, tablename, pd, userid, chartid, filte) {
var newDiv = document.createElement(pd);
var change = " onchange='dropchange(this)' ";
var html = '<select ' + change + ' title="' + defaultvalue + '" id="' + dropid + '" name = "' + columname + '" >'
var obj = {};
obj.coluname = columname;
obj.tablename = tablename;
obj.userid = userid;
obj.chartid = chartid;
obj.filte = filte;
$.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 = "All";
var selected="true";
html += "<option Value='" + sel + "' title ='" + defaultvalue + "'>" + sel + "</option>";
for (i = 0; i < result.length; i++)
{
if(defaultvalue==result[i])
{
html += "<option selected='" + selected + "' value='" + result[i] + "'>" + result[i] + "</option>";
}
else {
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 ');
}
});
}
var a =$.trim($("[id*=chart0Filter2drop0]").val());