Solved

Displaying text only when onMouseOver event occurs

Posted on 2002-07-15
7
173 Views
Last Modified: 2008-03-17
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
Comment
Question by:icarey
7 Comments
 
LVL 30

Expert Comment

by:third
ID: 7156163
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7156246
<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
 
LVL 2

Expert Comment

by:mgaurav
ID: 7156263
<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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:zeheb
ID: 7156789
<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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 200 total points
ID: 7157053
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
 
LVL 3

Author Comment

by:icarey
ID: 7166083
Thanks to all for your answers
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7166710
Glad we could help. Thanks for the A. :^)

Cd&
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now