By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

Hide and show images by mouse event

P: 2
Hi

I am developing an website. So in that i m trying to make like an image slide show. just like in www.habtoor.com. But i am using 3 buttons on leftside. 6 images are used for this 3 buttons. It means 2 images for each button. One ia on mouse over and anthor is on mouse out. Along with this, when mouse over on any particular button it displays the respective image on right side.so for right side i am using 3 images. when mouseover on any particular button on leftside it display an respective image by hiding other 2 images. so til this point i wrrten an code.
The code as shown below.

Expand|Select|Wrap|Line Numbers
  1. <!-- head part -->
  2. <!-- This script is for hide nd show images on right side -->
  3.  
  4. <script type="text/javascript" language="JavaScript">
  5. function HideDIV(d) 
  6. document.getElementById(d).style.display = "none"; 
  7. }
  8. function DisplayDIV(d)
  9.  { 
  10.  document.getElementById(d).style.display = "block"; 
  11.  }
  12.  </script>
  13.  
  14. <!--This script is for images used for button, I musing 2 images for each button(green nd white) --> 
  15.  
  16.  <SCRIPT LANGUAGE="JavaScript">
  17.  
  18. greenoverview = new Image();
  19. greenoverview.src = "http://bytes.com/images/iskanwap/green_over.jpg";
  20. whiteoverview = new Image();
  21. whiteoverview.src = "http://bytes.com/images/iskanwap/white_over.jpg";
  22.  
  23. greenconstruction = new Image();
  24. greenconstruction.src = "http://bytes.com/images/iskanwap/green_con.jpg";
  25. whiteconstruction = new Image();
  26. whiteconstruction.src = "http://bytes.com/images/iskanwap/white_con.jpg";
  27.  
  28.  
  29. greenreal = new Image();
  30. greenreal.src = "http://bytes.com/images/iskanwap/green_real.jpg";
  31. whitereal = new Image();
  32. whitereal.src = "http://bytes.com/images/iskanwap/white_real.jpg";
  33.  
  34. construction = new Image();
  35. construction.src = "http://bytes.com/images/iskanwap/green_over.jpg";
  36.  
  37. </script>
  38. <style type="text/css">
  39.  
  40.  
  41. #top-zone{overflow:visible; width:960px; margin:0 auto; height:20px;} /*Here to keep images hidden in IE mostly*/
  42. <!-- end of head part -->
  43.  
  44. <!-- Body part -->
  45. <!-- this is the body part, 1st <td> contain 1st button with 2 images --> 
  46.  
  47. <tr><td><span onmouseover="HideDIV('defaultDiv');HideDIV('constructionDiv');HideDIV('realDiv');DisplayDIV('overviewDiv')" onmouseout="HideDIV('defaultDiv');HideDIV('realDiv');HideDIV('constructionDiv');DisplayDIV('overviewDiv')"style="cursor:pointer"><a href="overview.php" onMouseOver="image1.src=greenoverview.src;" onMouseOut="image1.src=whiteoverview.src;"><img name="image1" src="http://bytes.com/images/iskanwap/white_over.jpg" border=:"0"></a></span></td>
  48.  
  49. <!-- this <td> tag contain right part images -->
  50.  
  51. <td rowspan="4">
  52. <div id="defaultDiv" class="mybox" style="background-image:url('images/iskanwap/over.jpg'); background-position:left; background-repeat:no-repeat; border:0"></div>
  53.  
  54. <div id="overviewDiv" class="mybox" style="display:none;":><span onmouseover="HideDIV('defaultDiv');DisplayDIV('overviewDiv')" style="cursor:pointer"><a href="overview.php"><img src="http://bytes.com/images/iskanwap/over.jpg" onmouseover="image1.src=greenoverview.src;" onmouseout="image1.src=whiteoverview.src;" border="0"/></span></div>
  55.  
  56. <div id="constructionDiv" class="mybox" style="display:none;":><span onmouseover="HideDIV('defaultDiv');HideDIV('overviewDiv')" style="cursor:pointer"><a href="construction.php" onMouseOver="image2.src=greenconstruction.src;" onMouseOut="image2.src=whiteconstruction.src;"><img src="http://bytes.com/images/iskanwap/CONSTRUCTION2.jpg" border="0" /></span></div>
  57.  
  58. <div id="realDiv" class="mybox" style="display:none;":><span onmouseover="HideDIV('defaultDiv');HideDIV('overviewDiv')" style="cursor:pointer"><a href="realestate.php" onMouseOver="image3.src=greenreal.src;" onMouseOut="image3.src=whitereal.src;"><img src="http://bytes.com/images/iskanwap/real_estate.jpg" border="0" /></span></div>
  59. </td>
  60. </tr>
  61.  
  62. <!-- below 2 row contain a 2 button--> 
  63.  
  64. <tr>
  65. <td><span onmouseover="HideDIV('defaultDiv');HideDIV('overviewDiv');HideDIV('realDiv');DisplayDIV('constructionDiv')" onmouseout="HideDIV('defaultDiv');HideDIV('overviewDiv');HideDIV('realDiv');DisplayDIV('constructionDiv')" style="cursor:pointer"><a href="construction.php" onMouseOver="image2.src=greenconstruction.src;" onMouseOut="image2.src=whiteconstruction.src;"><img name="image2" src="http://bytes.com/images/iskanwap/white_con.jpg" border=0></a></span></td>
  66. </tr>
  67. <tr>
  68.   <td><span onmouseover="HideDIV('defaultDiv');HideDIV('overviewDiv');HideDIV('constructionDiv');DisplayDIV('realDiv')" onmouseout="HideDIV('defaultDiv');HideDIV('overviewDiv');HideDIV('constructionDiv');DisplayDIV('realtDiv')" style="cursor:pointer"><a href="realestate.php" onmouseover="image3.src=greenreal.src;" onmouseout="image3.src=whitereal.src;"><img name="image3" src="http://bytes.com/images/iskanwap/white_real.jpg" border=0/></a></span></td>
  69. </tr>
  70.  
  71. <!-- End of body part -->
  72.  
Now what i want is when mouse out of all these images. It should behave like an slide show. By heightlighting an each button by changing the image of the button by keeping the other 2 button images same. Along with the respective image on right side.
Thankoyu. ANyone knows solution for my problem please help.
Apr 6 '11 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
Expand|Select|Wrap|Line Numbers
  1. <div style="cursor: pointer; color: white; width: 100px; height: 30px; line-height: 30px; font-weight: bold; background-image: url(webapp/gui/img/normal.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; " 
  2.             align="center" onmouseover="this.style.background='url(webapp/gui/img/onmouseover.png)'" onmouseup="this.style.background='url(webapp/gui/img/onmouseover.png)'" onmousedown="this.style.background='url(webapp/gui/img/onclick.png)'" onmouseout="this.style.background='url(webapp/gui/img/normal.png)'" 
  3.             onclick="getStaticAction('Reports','SaveBankTranseferCharge','TransferCharge='+document.getElementById('TransferCharge').value+'&RecordId=<?=$DateRange?>',function(textReturn){if(textReturn=='failed') alert('Data Saving Failed'); else alert('Saved Successfully');});">Save</div>
  4.  
get the clue from here
Apr 7 '11 #2

P: 2
Thanku for replying.
But i am using 6 images simultaniously when mouseout. Even in this also i want to hide some images respectively. That is what i am not getting. Please tel me how to do that one.
Apr 7 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.