Hi
I am making a picture gallery in javascript php and mysql.Its running great when using separate image as input type.But when I am mapping a single image into 2 then the picture gallery is not working…Lets show you the code.
[CODE]<table width=”33%” border=”0″>
<?
$show=”none”;
$sql=mysql_query(“SELECT * FROM project_pic where pid=’1′”);
if(mysql_num_rows($sql)>0)
{
$i=1; if($i==1) $show=””;
global $count;
$count=mysql_num_rows($sql);
while($row=mysql_fetch_array($sql))
{
?>
<tr>
<td id=”tdid1<?=$i?>” style=”display:<?=$show?>” align=”center” width=”33%” height=”30%”><img src=”../proj_pics/<?=$row[filename]?>” width=”100″ height=”100″ border=”0″></td>
</tr>
<tr>
<td id=”tdid2<?=$i?>” style=”display:<?=$show?>” align=”center” width=”33%” height=”10%”>
Picture #
<?=$i?>
<?=$row[title]?>
<input type=”image” name=”prev<?=$i?>” onClick=”prev(<?=$i?>)” src=”some1.gif”>
<input type=”image” name=”next<?=$i?>” onClick=”next(<?=$i?>)” src=”some2.gif”> </td>
<?
$i++;
$show=”none”;
echo “</tr>”;
}
}
?>
</table>
and the javascript function
[CODE]<script language=”javascript”>
var c=<?=$count?>;
function next(i)
{
if(i<c)
{
eval(“tdid1″+i+”.style.display=’none'”);
eval(“tdid2″+i+”.style.display=’none'”);
//eval(“tdid3″+i+”.style.display=’none'”);
var n=i+1;
eval(“tdid1″+n+”.style.display=””);
eval(“tdid2″+n+”.style.display=””);
//eval(“tdid3″+n+”.style.display=””);
}
}
function prev(i)
{
if(i>1)
{
eval(“tdid1″+i+”.style.display=’none'”);
eval(“tdid2″+i+”.style.display=’none'”);
//eval(“tdid3″+i+”.style.display=’none'”);
var n=i-1;
eval(“tdid1″+n+”.style.display=””);
eval(“tdid2″+n+”.style.display=””);
//eval(“tdid3″+n+”.style.display=””);
}
}
</script>
The above is working great but when I am using usemap then not…
[CODE]<table width=”33%” border=”0″>
<?
$show=”none”;
$sql=mysql_query(“SELECT * FROM project_pic where pid=’1′”);
if(mysql_num_rows($sql)>0)
{
$i=1; if($i==1) $show=””;
global $count;
$count=mysql_num_rows($sql);
while($row=mysql_fetch_array($sql))
{
?>
<tr>
<td id=”tdid1<?=$i?>” style=”display:<?=$show?>” align=”center” width=”33%” height=”30%”><img src=”../proj_pics/<?=$row[filename]?>” width=”100″ height=”100″ border=”0″></td>
</tr>
<tr>
<td id=”tdid2<?=$i?>” style=”display:<?=$show?>” align=”center” width=”33%” height=”10%”>
Picture #
<?=$i?>
<?=$row[title]?>
<img src=”playerbuttons.gif” width=”69″ height=”32″ border=”0″ usemap=”#Map”><map name=”Map”>
<area shape=”circle” coords=”13,15,11″ name=”prev<?=$i?>” onclick=”prev(<?=$i?>)” input type=”image”>
<area shape=”circle” coords=”45,15,11″ name=”next<?=$i?>” onclick=”next(<?=$i?>)” input type=”image”>
</map>
</td>
<?
$i++;
$show=”none”;
echo “</tr>”;
}
}
?>
</table>
in this usemap case the onclicks are getting the value but after 1st click the 2nd image is coming but then after no images and prev() is not working.Is it impossible to use usemap within a loop and call onclick function staying within that loop.
Any suggestion is highly welcomed.Thanks in advance.
Raj.