Solved

show/hide Div  on mouseover

Posted on 2010-09-01
8
788 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 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

828 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