标签:
推荐 :http://www.cnblogs.com/Peter-Zhang/archive/2011/10/22/2221147.html
eg:
1 $("#txtGrand").autocomplete("/AjaxHandlers/StudentContractHandler.ashx", { 2 multiple: false, 3 mustMatch: true, 4 width: 140, 5 extraParams: { action: "subname", province: ‘0‘ }, 6 parse: function (data) { 7 var parsed = []; 8 if (data != "") { 9 data = eval("(" + data + ")"); 10 for (var i = 0; i < data.length; i++) { 11 parsed[parsed.length] = { 12 data: data[i], 13 value: data[i].usercode, 14 result: data[i].username //返回的结果显示内容 15 }; 16 } 17 } 18 return parsed; 19 }, 20 formatItem: function (row, i, max) { 21 return "<div value=‘" + row.usercode + "‘ >" + row.userinfo + "</div>"; 22 }, 23 formatResult: function (row) { 24 return item.usercode; 25 } 26 }).result(function (event, item, formatted) {//选择后操作 27 if (document.getElementById("txtGrand").value != "") { 28 $("#visVal").val(""); 29 $("#txtGrand").val(item.username); 31 $("#visVal").val(item.usercode);35 } 36 });
标签:
原文地址:http://www.cnblogs.com/kongxp/p/4730738.html