Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

show/hide Div  on mouseover

Posted on 2010-09-01
8
Medium Priority
?
813 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
8 Comments
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 1600 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 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

810 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