<script type="text/javascript"> var emails = [ { name: "Peter Pan", to: " peter@pan.de", cc:[{name:"aa",to:"aa.com"},{name:"bb",to:"aa.com"},{name:"cc",to:"aa.com"},{name:"dd",to:"aa.com"}]}, { name: "Molly", to: " molly@yahoo.com", cc:[{name:"ee",to:"aa.com"},{name:"aa",to:"aa.com"},{name:"aa",to:"aa.com"},{name:"aa",to:"aa.com"}]}, { name: "Forneria Marconi", to: " live@japan.jp",cc:[{name:"aa",to:"aa.com"},{name:"aa",to:"aa.com"},{name:"aa",to:"aa.com"},{name:"aa",to:"aa.com"}] } ]; $(function() { var aa=new Array();var k=0; for(var i=0;i<emails.length;i++){ for(var j=0;j<emails[i].cc.length;j++){ aa[k]='{name:"'+emails[i].cc[j].name+'",to:"'+emails[i].cc[j].to+'"}'; k++; } } var bb=aa.join(","); var cc='['+bb+']'; var dd=eval(cc);$('#keyword').autocomplete(dd, { max: 12, //列表里的条目数 minChars: 0, //自动完成激活之前填入的最小字符 width: 400, //提示的宽度,溢出隐藏 scrollHeight: 300, //提示的高度,溢出显示滚动条 matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示 autoFill: false, //自动填充 formatItem: function(row) { return row.name + ',' + row.to; }, formatMatch: function(row, i, max) { return row.name + row.to; }, formatResult: function(row) { return row.to; } }).result(function(event, row, formatted) { alert(row.to); }); </script> </head> <body> <form id="form1" runat="server"> <div> <input id="keyword" /> <input id="searchSchool" /> <input id="getValue" value="GetValue" type="button" /> </div> </form>