Form auto-complete, pass value and ID in background, and submit ID value to background

Source: Internet
Author: User
Tags php foreach

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.