js给DropdownList赋值

var row = [{ "code": "1", "model": "APOLLO" }, { "code": "2", "model": "APOLLO M/B1"}];
for (var i = 0; i < row.length; i++) {
  var addOption = document.createElement("option");
  addOption.text = row[i]["model"];
  addOption.value = row[i]["model"];
  document.getElementById("ddlModel").add(addOption);
}
<asp:DropDownList ID="ddlModel" name="ddlModel" runat="server" Font-Size="9pt" Width="105px"
  CssClass="DropDownList">
</asp:DropDownList>

 

posted @ 2016-11-08 16:02  冷战  阅读(5067)  评论(0编辑  收藏  举报