Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 9th, 2007, 12:54 PM
Registered User
 
Join Date: May 2007
Location: kolkata, West Bengal, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to raj_2006
Default onclick with usemap problem

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.


<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?>
      &nbsp;
      <?=$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


<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...


<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?>
      &nbsp;
      <?=$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.


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button OnClick problem john6630 ASP.NET 2.0 Basics 2 September 21st, 2007 05:44 PM
Weird problem with dropdown onclick event in IE 7. tovipul21 Classic ASP Basics 1 September 7th, 2007 01:15 PM
onclick problem hubertc Javascript How-To 1 October 19th, 2006 04:44 AM
onClick crmpicco Javascript How-To 1 March 21st, 2005 09:18 AM
onClick event problem mateenmohd Javascript 8 August 2nd, 2003 05:16 AM



All times are GMT -4. The time now is 10:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.