01.
<!DOCTYPE html>
02.
<html>
03.
<head>
04.
<!-- libs jQuery -->
06.
<!-- CSS -->
07.
<link rel=
"stylesheet"
type=
"text/css"
href=
"style.css"
/>
08.
09.
<title>jQuery suggession</title>
10.
<meta charset=
"UTF-8"
/>
11.
12.
</head>
13.
14.
<body>
15.
<h4>Monster team.</h4><hr />
16.
<div id=
"frm_app"
align=
"center"
>
17.
<form name=
"Myfrm"
id=
"Myfrm"
>
18.
<label>Search:</label>
19.
<input type=
"text"
name=
"txt_src"
id=
"txt_src"
onblur=
"setTimeout('unfocus()', 200);"
/><br />
20.
<div id=
"result"
></div>
21.
</form>
22.
</div>
23.
<script type=
"text/javascript"
>
24.
$(document).ready(
function
(){
25.
$(
'#result'
).hide();
26.
27.
$(
'#txt_src'
).keyup(
function
(){
28.
var
txt_src = $(
'#txt_src'
).val();
29.
if
(txt_src !=
""
){
30.
$.get(
'server.php'
, {qrstr : txt_src},
function
(data){
31.
if
(data !=
""
){
32.
$(
'#result'
).fadeIn(200).html(data);
33.
34.
}
else
{
35.
$(
'#result'
).hide();
36.
}
37.
38.
});
39.
}
else
{
40.
$(
'#result'
).hide().html(
''
);
41.
}
42.
43.
});
44.
});
45.
46.
47.
function
Add_val(data){
48.
$(
'#txt_src'
).val(data);
49.
$(
'#result'
).hide().html(
''
);
50.
}
51.
52.
function
unfocus(){
53.
$(
'#result'
).fadeOut(200).html(
''
);
54.
55.
}
56.
</script>
57.
</body>
58.
</html>