Sto lavorando su questo codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
var tIdX = '';
var imgIndex = -1;
var arrImg = new Array();
var speed = 4000;
<?php
//vado a leggere i banner nella tabella del mio db
$query = "SELECT * FROM banner";
$ri = mysql_query($query);
$i=1;
//creo un ciclo per generare l'array del js
while ( $dati = mysql_fetch_array($ri) ) {
$path = $dati["nomefile"];
?>
arrImg[$i] = <?php echo $path; ?>;
<?
$i++;
}
?>
function animateX() {
clearTimeout(tIdX);
if (imgIndex < arrImg.length-1) {
imgIndex++;
} else {
imgIndex = 0;
} // if (imgIndex <= arrImg.lenght-1)
document.getElementById('myImg').src = arrImg[imgIndex];
document.getElementById('myImg').alt = imgIndex;
tIdX=setTimeout('animateX()', speed);
} // function animateX()
//-->
</script>
</head>
<body>
[img][/img]
<script language="JavaScript" type="text/javascript">
<!--
animateX();
//-->
</script>
</body>
</html>
Il problema è che non mi carica l'array. Qualcuno sa aiutarmi?
Grazie

Rispondi quotando