今天尝试了一下jquery easy ui的combobox,感觉蛮好用的,直接上代码吧
HTML如下
<div>
<input id="btnBind" type="button" onclick="bindLanguage();" />
<asp:DropDownList ID="testChange" onchange="bindLanguage();" runat="server" >
</asp:DropDownList>
<input class="easyui-combobox" id="language" name="language"
data-options="valueField:'id',textField:'text',multiple:true" />
</div>
引用的JS库
<script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.easyui.min.js" type="text/javascript"></script>
<link href="CSS/easyui.css" rel="stylesheet" type="text/css" />
JS方法
<script language="javascript" type="text/javascript">
function bindLanguage() {
$('#language').combobox('setValue');
$.ajax({
url: "GetData.ashx",
cache: false,
async: false,
success: function (data) {
try {
var countList = eval(data);
$('#language').combobox('loadData', countList);
}
catch (ex) {
}
}
});
}
function onChange() {
alert(231);
}
</script>