Get data from the background, convert to array format
var autoComplete = new AutoComplete (' keyword ', ' auto ', [<?php foreach ($jqname as $key = = $dd) {$str = $str. "". $dd [' title ']. "',";} $str =substr ($str, 0, $str. length-1); Echo $str;;]);
get data from the background and convert it into JSON format, setting hidden fields
<input type= "hidden" value= ' <?php echo json_encode ($jqname)?> ' id= "Jq_json"/>
set hidden fields, store IDs value
<input type= "hidden" id= "jqid" name= "jqid" value= ""/>
add in mouse events and keyboard events, dynamic set ID value
When the mouse moves to the Div, the Div highlights
Autoonmouseover:function (_this, _div_index) {
return function () {
_this.index = _div_index;
var length = _this.autoobj.children.length;
for (var j = 0; J < length; J + +) {
if (j! = _this.index) {
_this.autoobj.childnodes[j].classname = ' auto_onmouseout ';
} else {
_this.autoobj.childnodes[j].classname = ' auto_onmouseover ';
_this.obj.value = _this.autoobj.childnodes[j].seq;
var Jq_json=document.getelementbyid ("Jq_json"). Value;
var data = eval (Jq_json);//Format an array of
for (var t = 0; t<data.length; t++) {
if (data[t][' title ']==_this.obj.value) {
var Td=document.getelementbyid ("Jqid");
td.value=data[t][' aid '];
Break
}
}
}
}
}
},
Change classname
Changeclassname:function (length) {
for (var i = 0; i < length; i++) {
if (i! = This.index) {
This.autoobj.childnodes[i].classname = ' auto_onmouseout ';
} else {
This.autoobj.childnodes[i].classname = ' auto_onmouseover ';
This.obj.value = This.autoobj.childnodes[i].seq;
var Jq_json=document.getelementbyid ("Jq_json"). Value;
var data = eval (Jq_json);//Format an array of
for (var j = 0; j<data.length; j + +) {
if (data[j][' title ']==this.obj.value) {
var Td=document.getelementbyid ("Jqid");
td.value=data[j][' aid '];
Break
}
}
}
}
},
Form auto-complete, pass value and ID in background, and submit ID value to background