dropdown values bind dynamically using jquery

Ankaprasad
Posted by Ankaprasad under jQuery category on | Points: 40 | Views : 228

var arrData=[]; // arrData can be array or key value pair
arrData.push({Key:1, value:val1});
arrData.push({Key:2, value:val2});

var options=FormatDDL (arrData);
$('#ddlAgent').append(options);

function  FormatDDL (data) {
var options;
options += '<option value="-Select-">-Select-</option>';
$.each(data, function (i) {
options += '<option value="' + data[i].Key + '">' + data[i].Value + '</option>';
});
return options;
}

Comments or Responses

Login to post response