-4
我需要填充從JSON一個下拉列表,我不能選擇從HTML頁面的DDL:爲什麼不能使用下拉列表?
<asp:DropDownList ID="ddlPopUp" runat="server" /> //HTML
//JaveScript 1 - returns empty ddl
ar DdlPopUp = "<%=ddlPopUp.ClientID %>";
function fillDDL(data) {
var obj = $.parseJSON(data.Data);
var myList = "";
for (var i = 0; i < obj.length; i++) {
myList += "<option>"+ obj[i] +"</option>";
}
DdlPopUp.html(myList);
}
//JaveScript 2 - dll always null
function fillDDL(data) {
var obj = $.parseJSON(data.Data);
var dll = document.getElementById('ddlPopUp');
for (var i = 0; i < obj.length; i++) {
dll.appendChild(obj[i]);
}
}
爲什麼它不工作?該怎麼辦 ?