No obtengo ninguna respuesta
Publicado por Smm (19 intervenciones) el 14/06/2014 10:10:28
Saludos tengo un pequeño problema y he probado ya de mil formas pero ni siquiera sale el alert.
tabien asi :
ASI TAMBIEN:
ASI es COMO lo tengo ahora:
Gracias y un saludo
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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function cargar(){
var matriz = new Array[];
var elementos = document.getElementById(sl1.options[0]);
for ( i = 0; i <= elementos; i++) {
matriz[i] = elementos[i].text;
}
alert(matriz);
}
</script>
<p id="resultado"></p>
<select id="sl1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<button id="bt1" onclick="cargar()">aceptar</button>
</body>
</html>
tabien asi :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script>
function cargar(){
var matriz = new Array[];
var elementos = document.getElementById(sl1);
for ( i = 0; i <= elementos.legth; i++) {
matriz[i] = elementos[i].text;
}
alert(matriz);
}
</script>
ASI TAMBIEN:
1
2
3
4
5
6
7
8
9
10
11
12
<script>
function cargar(){
var matriz = new Array[];
var elementos = document.getElementById(sl1.options[0]);
for ( i = 0; i <= elementos; i++) {
matriz[i] = new option (elementos[i].text);
}
alert(matriz);
}
</script>
ASI es COMO lo tengo ahora:
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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function cargar(){
var matriz = new Array[];
var elementos = document.getElementById(sl1).options[0];
for ( i = 0; i <= elementos; i++) {
matriz[i] = elementos[i].text;
}
alert(matriz);
}
</script>
<p id="resultado"></p>
<select id="sl1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<button id="bt1" onclick="cargar()">aceptar</button>
</body>
</html>
Gracias y un saludo
Valora esta pregunta
0