Foros del Web » Creando para Internet » HTML »

fallo al mostrar imagen

Estas en el tema de fallo al mostrar imagen en el foro de HTML en Foros del Web. Hola tengo este codigo: <html> <head> <script language="JavaScript" type="text/javascript"> function crear(){ var matriz1=new Array(5); for (i=0;i<5;i++){ matriz1[i]=new Image; matriz1[i].src=i+".jpg"; alert(matriz1[i].src); document.images['foto0'].src = matriz[i].src; } } ...
  #1 (permalink)  
Antiguo 18/01/2011, 03:08
 
Fecha de Ingreso: diciembre-2010
Mensajes: 459
Antigüedad: 13 años, 4 meses
Puntos: 21
fallo al mostrar imagen

Hola tengo este codigo:

<html>

<head>

<script language="JavaScript" type="text/javascript">


function crear(){

var matriz1=new Array(5);

for (i=0;i<5;i++){
matriz1[i]=new Image;
matriz1[i].src=i+".jpg";
alert(matriz1[i].src);
document.images['foto0'].src = matriz[i].src;
}


}
</head>

<body>
<table border="0" height="100%" width="100%">

<tr>

<td>
<center>

<img src="4.jpg" height="150" width="150" name="foto0">
<img src="3.jpg" height="150" width="150" name="foto1">
<img src="2.jpg" height="150" width="150" name="foto2">
<img src="1.jpg" height="150" width="150" name="foto3">
<img src="0.jpg" height="150" width="50" name="foto4">
<BR>




<button onClick="crear();"><img src="derecha.jpeg" height="20" width="50"></img></button>

</center>
</td>

</tr>

</table>

</body>

</html>


al comienzo las imagenes me las carga,cuando llama la funcion de javascript en el alert me parece bien la ruta pero no me carga la imagen,que tengo mal?

Gracias
  #2 (permalink)  
Antiguo 18/01/2011, 03:57
 
Fecha de Ingreso: diciembre-2010
Mensajes: 459
Antigüedad: 13 años, 4 meses
Puntos: 21
Respuesta: fallo al mostrar imagen

ok tenia el fallo aqui

document.images['foto0'].src = matriz[i].src; y la solucion

document.images['foto0'].src = matriz1[i].src;

y eso funciona, pero ahora quiero que en vez de

document.images['foto0'].src = matriz1[i].src;

sea

document.images['foto'+matriz[i].].src = matriz1[i].src;

para que coja el numero del for pero me sale error

alguna solución??

Etiquetas: fallo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:00.