• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Displaying text only when onMouseOver event occurs

Hello,
I would like to display text in an area only when an onMouseOver event occurs.
For example.
If I have a calendar on a page I would like to have events for the dates. When a user puts their mouse over the date or event on that date then a description of that event is displayed below the calendar. When they move the mouse away then the description of that event is no longer displayed.

How may this be possible.

Thanks,
Ivan
0
icarey
Asked:
icarey
1 Solution
 
lexxwernCommented:
<html>
<head>
<title>Tooltips</title>
</head>
<body>
<a nohref onmouseover="document.all.tooltip1.style.visibility='visible'" onmouseout="document.all.tooltip1.style.visibility='hidden'">This is My Text</a>
<div id="tooltip1" style="display;block; position:absolute; visibility:hidden; top:10px; left:10px; height:10px; width:100px; font-family:verdana; font-size:9px; border:1px solid #cccccc; background-color:#eeeeee">
This is my tooltip
</div>
</body>
</html>





or





<a nohref title="Your ToolTip">Your Text Here</a>
0
 
mgauravCommented:
<form name="myForm">
<textarea name="comments" value=""></textarea>
</form>

<a href="javascript://" onmouseover="tooltip('details')" onmouseout="tooltip('')" onclick="return false;">July 16, 2002</a>


<script>
 function tooltip(tip)
 {
   document.myForm.comments.value = tip;
 }
</script>


HIH,
mGaurav
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
zehebCommented:
<SCRIPT LANG="JavaScript">
    function ShowText()
    {
        document.all.item("DisplayText").innerText = "Some Text"
    }
   
    function HideText()
    {
        document.all.item("DisplayText").innerText = ""
    }
</SCRIPT>
</HEAD>
<BODY>
    <SPAN ID="DisplayText" OnMouseOver="JavaScript:ShowText()" OnMouseOut="JavaScript:HideText()">
    &nbsp
    </SPAN>
0
 
COBOLdinosaurCommented:
If you want it cross-browser, it get very limited because netscrap 4.x
only supports mouse over for links images and layers

<html>
<!-- cross-browser text display dynamically from mouseoveR a link
-->
<style>
   .EVNTcls {visibility:hidden;position:absolute;top:250;left:40}
   a:hover {color:white;background-color:blue}
</style>
<script language="JavaScript">
<!--
   var ACTIVElist=false;
// browser detection using DOM detection:

if (document.getElementById)
{
   var LoLev=false;
   var HiLev=true;
   var IE5=(document.all) ? true : false;
   var NS6=(!document.all) ? true : false;
}
else
{
   var HiLev=false;
   var LoLev=true;
   var IE4=(document.all) ? true : false;
   var NS4=(document.layers) ? true : false;
}

   function ShowBlock(EL)
   {
      if (NS4)
      {
         ACTIVElist=document.layers[EL];
      }
      else
      {
         if (IE4)
         {
            ACTIVElist=document.all[EL].style;
         }
         else
         {
            if (HiLev)
            {
               ACTIVElist=document.getElementById(EL).style;
            }
         }
      }
      ACTIVElist.visibility="visible";
   }
//-->
</script>
</head>
<body>

<div id="linklst" style=position:absolute;left:40;top:100">
   <a href="blah1.htm" onMouseOver="ShowBlock('id1')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah1
   </><br /><br />
   <a href="blah2.htm" onMouseOver="ShowBlock('id2')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah2
   </a><br /><br />
   <a href="blah3.htm" onMouseOver="ShowBlock('id3')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah3
   </a><br /><br />
   <a href="redirect_back.htm" onMouseOver="ShowBlock('id4')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah4
   </a><br /><br />
</div>
<div id="id1" class="EVNTcls">
   JULY 15TH EVENTS<br />
   1st event for July 15<br />
   another event for July 15th<br />
   etc
</div>
<!-- each list is in its own layer with only one visible at a time
-->
<div id="id2" class="EVNTcls" >
   JULY 16TH EVENTS<br />
   1st event for July 16<br />
   another event for July 16th<br />
   etc
</div>
<div id="id3" class="EVNTcls">
   JULY 17TH EVENTS<br />
   1st event for July 17<br />
   another event for July 17th<br />
   etc<br />
   etc ;)<br />
   etc [:)<br />
   etc {:x)<br />
   etc :=)<br />
   etc B}<br />
</div>
<div id="id4" class="EVNTcls">
   JULY 18TH EVENTS<br />
   1st event for July 18<br />
   another event for July 18th<br />
   etc
</div>
</body>
</html>

If you do not need to support Netscrap 4.x then you can put the
mouse events on any tag.

Cd&
0
 
icareyAuthor Commented:
Thanks to all for your answers
0
 
COBOLdinosaurCommented:
Glad we could help. Thanks for the A. :^)

Cd&
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now