Rotador de noticias con BD y JS no me muestra datos
Publicado por Guillermo (3 intervenciones) el 26/01/2014 05:15:53
Buenas tardes comunidad, mes dirijo a ustedes ya qeu estoy bastante perdido. Con el ejemplo de mi clase (que no se conecta a una base de datos) y con lo que he leido en este foro en otros temas, he llegado al siguiente código:
No me dá ningún error al ejecutar, pero no me muestra nada :(
Espero que me puedan ayudar, muchas gracias desde ya!!
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
<script language="javascript" type="text/javascript">
noticiero=new Array();
<?
while($row=mysql_fetch_array($consulta))
{
?>
noticia("<?=$row['pathFotoNoticia'];?>","<?=$row['titulo'];?>","<?=$row['pathNoticia'];?>","<?=$row['link'];?>");
<?
}
?>
espera=2 //Segundos de espera
function noticia(imagen,titulo,texto,enlace)
{
this.imagen=imagen;
this.texto=texto;
this.titulo=titulo;
this.enlace=enlace;
}
function mostrar_campo(id_campo)
{
return document.getElementById(id_campo);
}
function mostrar(a)
{
mostrar_campo("imagen_noticia").src=noticiero[a].imagen;
mostrar_campo("titulo_noticia").innerHTML=noticiero[a].titulo;
mostrar_campo("texto_noticia").innerHTML=noticiero[a].texto;
mostrar_campo("enlace").href=noticiero[a].enlace;
}
b=0;
function cambiar()
{
if (b<noticiero.length)
{
b++;
}
else
{
b=0;
}
mostrar(b);
}
// Cada "espera*1000" milisegundos
// cambia a la siguiente noticia
setInterval("cambiar()",espera*1000);
</script>
No me dá ningún error al ejecutar, pero no me muestra nada :(
Espero que me puedan ayudar, muchas gracias desde ya!!
Valora esta pregunta
0