Hello I got this script.
The proiblem is that when i load the page, it does not appear the first image of the gallery, but it's empty.
Due to the fact that in img src="" i don't know which is the correct js code to write.
So, the first image is empty. To see the images i have to push the "forward button"..
But i wish to have the first image of the list seen automatically as the web page is loaded.
Any ideas? Here it is:
$sql = "SELECT * FROM varie ORDER BY descrizione";
$result = mysql_query ($sql);
while ($row = mysql_fetch_row($result))
{
echo "photos[".$item."]=\"varie/".$row[0].".jpg\";";
$item=$item+1;
}
}
?>
function arrow()
{
document.getElementById( "back2" ).style.display = "none";
}
function changePic(dir) {
var image = document.images.photoslider,
fwdBtn = document.getElementById('forward2'),
backBtn = document.getElementById('back2'),
n = photos.length-1;
if (dir == "next") {
which = (which < n) ? which + 1 : which;
image.src = photos[which];
backBtn.style.display = "inline";
if (which == n) {
fwdBtn.style.display = "none";
}
} else if (dir == "back") {
which = (which > 0) ? which - 1 : which;
image.src = photos[which];
fwdBtn.style.display = "inline";
if (which === 0) {
backBtn.style.display = "none";
}
}
return false;
}
</script>
</head>
<body onLoad="arrow()">
<div class="container2">
<div id="logo" > <img title="logo" src="logo2.jpg"></div>
<div class="menu">
<a href=" </a>
<a href=" sono </a>
<a href=" </a>
<a href=" </a>
<a href=" </a>
</div>
<div id="backvarie">
<a href="#" onclick="return changePic('back');">
<img id="back2" style="border:0px" src="indietro.jpg"></a>
</div>
<div class="centro">
<div class="gruppofoto2"><a href="gallerymacro.php">Macro</a><a href="gallerypaesaggi.php">Paesaggi</a><a href="galleryritratti.php">Ritratti</a><a href="gallerybn.php">B&N</a><a href="gallerynotturna.php">Notturna</a><a href="galleryvarie.php">Varie</a><img src=" (THIS IS THE PROBLEM..what is the right code?) " name="photoslider">
</div>
</div>
<div id="forward"><a href="#" onclick="return changePic('next');"> <img id="forward2" style="border:0px" src="avanti.jpg"></a>
</div>
<div class="inizio"><a href="#" onclick="which=1; changePic('back');return false" >Torna all'inizio della gallery</a>
</div>
<div id="footer">Created by Paolo Bergomi</div>
</div>
thanks to e.b.
The proiblem is that when i load the page, it does not appear the first image of the gallery, but it's empty.
Due to the fact that in img src="" i don't know which is the correct js code to write.
So, the first image is empty. To see the images i have to push the "forward button"..
But i wish to have the first image of the list seen automatically as the web page is loaded.
Any ideas? Here it is:
$sql = "SELECT * FROM varie ORDER BY descrizione";
$result = mysql_query ($sql);
while ($row = mysql_fetch_row($result))
{
echo "photos[".$item."]=\"varie/".$row[0].".jpg\";";
$item=$item+1;
}
}
?>
function arrow()
{
document.getElementById( "back2" ).style.display = "none";
}
function changePic(dir) {
var image = document.images.photoslider,
fwdBtn = document.getElementById('forward2'),
backBtn = document.getElementById('back2'),
n = photos.length-1;
if (dir == "next") {
which = (which < n) ? which + 1 : which;
image.src = photos[which];
backBtn.style.display = "inline";
if (which == n) {
fwdBtn.style.display = "none";
}
} else if (dir == "back") {
which = (which > 0) ? which - 1 : which;
image.src = photos[which];
fwdBtn.style.display = "inline";
if (which === 0) {
backBtn.style.display = "none";
}
}
return false;
}
</script>
</head>
<body onLoad="arrow()">
<div class="container2">
<div id="logo" > <img title="logo" src="logo2.jpg"></div>
<div class="menu">
<a href=" </a>
<a href=" sono </a>
<a href=" </a>
<a href=" </a>
<a href=" </a>
</div>
<div id="backvarie">
<a href="#" onclick="return changePic('back');">
<img id="back2" style="border:0px" src="indietro.jpg"></a>
</div>
<div class="centro">
<div class="gruppofoto2"><a href="gallerymacro.php">Macro</a><a href="gallerypaesaggi.php">Paesaggi</a><a href="galleryritratti.php">Ritratti</a><a href="gallerybn.php">B&N</a><a href="gallerynotturna.php">Notturna</a><a href="galleryvarie.php">Varie</a><img src=" (THIS IS THE PROBLEM..what is the right code?) " name="photoslider">
</div>
</div>
<div id="forward"><a href="#" onclick="return changePic('next');"> <img id="forward2" style="border:0px" src="avanti.jpg"></a>
</div>
<div class="inizio"><a href="#" onclick="which=1; changePic('back');return false" >Torna all'inizio della gallery</a>
</div>
<div id="footer">Created by Paolo Bergomi</div>
</div>
thanks to e.b.