-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathautocompletar.js
65 lines (55 loc) · 1.7 KB
/
autocompletar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/******************************************
* Autocompletar creado por Geynen Montenegro Cochas
* Copyright Geynen.
* Fecha: 03-02-2011 Chiclayo - Perú
* Version: 1.0
* http://geynen.wordpress.com
* Ref: http://blog.rarecore.eu/autocompleter-using-xajax-updated.html
******************************************/
function autocompletar_blur(div) {
window.setTimeout('autocompletar_blur2(\'' + div + '\')', 300);
}
function autocompletar_blur2(div) {
document.getElementById(div).style.display="none";
}
function autocompletar_teclado(div, tabladiv, keyc) {
var child = document.getElementById(tabladiv).rows;
var indice = -1;
for(var i=0; i < child.length; i++) {
if(child[i].className == 'tr_hover') {
indice = i;
}
if(i % 2==0){
child[i].className = 'impar';
}else{
child[i].className = 'par';}
}
// return
if(keyc == 13) {
var seleccionado = '';
if(child[indice].id) {
seleccionado = child[indice].id;
} else {
seleccionado = child[indice].id;
}
mostrarPersona(seleccionado);
} else {
// abajo
if(keyc == 40) {
if(indice == (child.length - 1)) {
indice = 1;
} else {
if(indice==-1) indice=0;
indice++;
}
// arriba
} else if(keyc == 38) {
indice--;
if(indice==0) indice=-1;
if(indice < 0) {
indice = (child.length - 1);
}
}
child[indice].className = 'tr_hover';
}
}