Solved

show/hide Div  on mouseover

Posted on 2010-09-01
8
799 Views
Last Modified: 2013-11-19
I have an image in web page inside a td. On mouse hover I want to show a div, right below the image, and I want the div to look like a drop down from the td.

Please help. any suggestions , urls will be helpful.


<td runat="server" id="tdShoppingCart" width="20%"  
style="background-color: #E5E5E5; height: 4px;" class="search">
<img src="Assets/Images/Master/shoppingcart.jpg"                 style="height: 34px; width: 60px; "   onmouseover="ShowCart('divCart')" onmouseout="HideCart('divCart');" />
 <div    id="divCart"    style="display:none;       position:absolute;       border-style: solid; background-color: #E5E5E5; height: 4px;      padding: 5px;" class="search">
 ctent here</div>
 </td>

Open in new window

0
Comment
Question by:TrialUser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 400 total points
ID: 33576041

<html>
<head>
<script language="javascript"> 

function ShowCart(id) {
	var ele = document.getElementById(id);
	ele.style.display = "block";
}

function HideCart(id) {
	var ele = document.getElementById(id);
  ele.style.display = "none";            
}
 
</script>
</head>

<body>
<table>
<tr>
<td runat="server" id="tdShoppingCart" width="20%"  
style="background-color: #E5E5E5; height: 4px;" class="search">
<img src="myImage.jpg"                 style="height: 34px; width: 60px; "   onmouseover="ShowCart('divCart')" onmouseout="HideCart('divCart');" />
 <div    id="divCart"    style="display:none;       position:absolute;       border-style: solid; background-color: #E5E5E5; height: 4px;      padding: 5px;" class="search">
 ctent here</div>
 </td>
 </tr>
 </table>
 </body>
 </html>

Open in new window

0
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 100 total points
ID: 33576051
Give the divCart a location top:XXpx; left:XXpx; and visibility:hidden and apply the javascript.
<script language="javascript" type="text/javascript">
function ShowCart(divId) {
    document.getElementById(divId).style.display = 'block';
    document.getElementById(divId).style.visibility = 'visible';
}
function HideCart(divId) {
    document.getElementById(divId).style.display = 'none';
    document.getElementById(divId).style.visibility = 'hidden';
}
</script>

Open in new window

0
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 33576068
Why dont you use a javascript library such as Scriptaculous. There are many animations and effects you can use for this kind of thing, for example:

http://speckyboy.com/2008/04/26/20-top-scriptaculous-scripts-you-cant-live-without/
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:TrialUser
ID: 33576074
Thanks for your response. My problem is how can i make sure the div is placed right below my td. It should appear like it is an extension of the td, as though it is a drop down from the td. Thanks. Please help
0
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 33576075
This looks like it is pretty similar to what you need:

http://www.exit404.com/lab/unobtrusive-persistent-scriptaculous/
0
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 33576106
The blind down effect is simply:

Effect.BlindDown
0
 
LVL 22

Expert Comment

by:kadaba
ID: 33579316
using a library is always advantageous....
by the way in the previous post you could just very the position of the div and get it right down the td.
0
 

Author Closing Comment

by:TrialUser
ID: 33595835
thanks t on for your response
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question