
porque no me cambia el foco
Publicado por Sergio (19 intervenciones) el 06/06/2014 22:35:30
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
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function siguiente() {
var opcion=document.getElementById('lista');
var posicion1=opcion.selectedIndex + 1;
if (opcion.selectedIndex >= 0) {
opcion.focus(posicion1);
alert(opcion.value);
/** =========== Esto esta desabilitado; posicion.innerHtml = opcion.value;**/
}
}
</script>
<select id="lista" size="3" >
<option>1aaaaaaaaaaaaaaaaa</option>
<option>2bbbbbbbbbbbbbbbbb</option>
<option>3ccccccccccccccccc</option>
</select>
<p id="posicion"></p>
<button id="prev" onclick="cargar()">prev</button><button id="next" onclick="siguiente()">siguiente</button>
</body>
</html>
=============================================================
ahora si que me lo hace pero no me cambia el focus lo deja en el que pulso.
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
<body>
<script>
function siguiente() {
var opcion=document.getElementById('lista');
var posicion1=opcion.selectedIndex;
if (opcion.selectedIndex >= 0) {
posicion1 += 1;
opcion.focus(posicion1);
alert(posicion1);
/** =========== Esto esta desabilitado; posicion.innerHtml = opcion.value;**/
}
}
</script>
<select id="lista" size="3" >
<option>1aaaaaaaaaaaaaaaaa</option>
<option>2bbbbbbbbbbbbbbbbb</option>
<option>3ccccccccccccccccc</option>
</select>
<p id="posicion"></p>
<button id="prev" onclick="cargar()">prev</button><button id="next" onclick="siguiente()">siguiente</button>
</body>
Valora esta pregunta


0