Salve ragazzi, sul mio sito utilizzo uno script per la visualizzazione delle foto, in pratica tutto funziona ma ho problemi nel visualizzare il numero della foto visualizzata in quel momento.
Codice PHP:
<script type="text/javascript">
//<![CDATA[
<!--
// Image Functions
// changeImage() and preload() functions for rollovers and GIF animation
// 19990326
// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at [url]http://www.dansteinman.com/dynapi/[/url]
// [url]http://kia.etel.ru/lib/dynduo/dynduo/index.html[/url]
function preload(imgObj,imgSrc) {
if (document.images) {
eval(imgObj+' = new Image()')
eval(imgObj+'.src = "'+imgSrc+'"')
}
}
<?
if ($row_3!=NULL) {
echo "preload('image1','/img/big/$row_2[nome]')\n\r";
}
else
{
echo "preload('image1','/img/logo.jpg')\n\r";
}
$i=1;
while ($row_2=mysql_fetch_array($result_2)) {
$i = $i+1;
echo "preload('image$i','/img/big/$row_2[nome]')\n\r"; } ?>
function changeImage(layer,imgName,imgObj) {
if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
else document.images[imgName].src = eval(imgObj+".src");
}
var imgCorrente = 1;
var numImages = <? echo $i; ?>;
function NextImage(){
if (imgCorrente < numImages) {
imgCorrente = imgCorrente +1;
changeImage(null, 'myImg', 'image'+imgCorrente);
document.all.tags("h6")[0].innerHTML = "Foto " + imgCorrente + " di " + numImages
}
}
function PreviousImage(){
if (imgCorrente > 1) {
imgCorrente = imgCorrente - 1;
changeImage(null, 'myImg', 'image'+imgCorrente);
document.all.tags("h6")[0].innerHTML = "Foto " + imgCorrente + " di " + numImages
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<? if ($num_img==0) { ?>
[img]/img/logo.jpg[/img]" name="myImg" width="500" class="bordo_imgimm" id="myImg" /></div>
<? } ?>
<? if ($row_3!=NULL) { ?>
[url="/ita/foto-gallery-immobile.php?id=<? echo $row_1[id]; ?>"][img]/img/db/big-salento-immobiliare.jpg[/img]" name="myImg" width="500" border="0" class="bordo_imgimm" id="myImg" />[/url]</div>
<? } ?>
<table width="100%" border="0" cellpadding="0">
<tr>
<td></td>
</tr>
<tr>
<td><table width="300" border="0" align="center" cellpadding="0">
<tr align="center" valign="middle">
<td>[url="Javascript:PreviousImage();"][img]/img/indietro.gif[/img][/url]</td>
<td>[b]Foto numero dell'immagine corrente di <? echo $i; ?>[/b]</td>
<td>[url="Javascript:NextImage();"][img]/img/avanti.gif[/img][/url]</td>
</tr>
</table></td>
</tr>
</table>
<script type="text/javascript">
if (numImages != 0){
changeImage(null, 'myImg', 'image'+imgCorrente);
document.all.tags("h6")[0].innerHTML = "Foto " + imgCorrente + " di " + numImages;
}
</script>
Qualche anima buona mi aiuta a capire come potrei risolvere tale problema?
Grazie anticipatamente.