LTY83
asked on
onmouseover show layer position right by mouse arrow
hi everyone,
i am pulling records from a db and displaying them in single line format - per record
i want to give basic details on the line displayed, but when the person mouseovers the record and holds it for say 2 or 3 seconds on that record it would display a css layer that would display more details about that record. now i'm not sure how to put the delay in so that when they mouseover it doesn't show up for say 2 or 3 seconds, and i'm also unsure of how to set the css layer positions so that the layer shows up next to the mouse cursor everytime, as long as the person is mousing over a record being shown
hopefully this is enough info,
thanks guys!
i am pulling records from a db and displaying them in single line format - per record
i want to give basic details on the line displayed, but when the person mouseovers the record and holds it for say 2 or 3 seconds on that record it would display a css layer that would display more details about that record. now i'm not sure how to put the delay in so that when they mouseover it doesn't show up for say 2 or 3 seconds, and i'm also unsure of how to set the css layer positions so that the layer shows up next to the mouse cursor everytime, as long as the person is mousing over a record being shown
hopefully this is enough info,
thanks guys!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hey one quick question, i know i'm being picky but is there anyway to make it so when you move the mouse the layer moves w/ it, i think taht would really cool
thanks
thanks
Try adding this to the <td>
onmousemove="showit('row1' );"
onmousemove="showit('row1'
ASKER
can't thank you enough, this is gonna be awesommmmeee!!!!!! THANKS BRO!
Hey...I've noticed it's a little sloppy. I've composed a solution - gimme a sec...
ASKER
yea i saw a couple bugs, but dude the idea is right on
ASKER
hows the new solution comin? i added some css to the div, different css for colors/font styles etc and it seems when i mouseover they appear to show up a lot lower than the cell, plus on mouseout sometimes it doesn't make the layer dissappear, u probably already know this just lettin ya know if you had any thoughts
thanks man
thanks man
still doing some research - it's hard to come by
ASKER
yea its a tough one, but i really appreciate everything, this is gonna be so sweet
Hey...
This works better. However, There's a lot of hard-coding involved (unfortunately), which can be tricky. Since you're using dynamic data (from a database), you'll have to change all hardcoded values (such as, like, looping from "row1" to "row3" you'll have to loop from "row1" to "row_" where _ is the total number of rows.
Let me know if this code works better for you:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Start hiding from old browser
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Eve nt.MOUSEMO VE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
//document.Show.MouseX.val ue = tempX
//document.Show.MouseY.val ue = tempY
for (var i=1;i<4;i++) {
document.getElementById('r ow' + i.toString()).style.pixelT op = tempY+2;
document.getElementById('r ow' + i.toString()).style.pixelL eft = tempX+2;
}
return true
}
function showit(on) {
var o = document.getElementById(on );
o.style.position = 'absolute';
o.style.display = 'inline';
}
function hideit(on) {
var o = document.getElementById(on );
o.style.display = 'none';
}
// timeout integers
function ReadyForShowing(the_row) {
var i = setTimeout("showit('" + the_row + "')",2000);
return i;
}
function StopShowing(the_row, the_to) {
clearTimeout(the_to);
hideit(the_row);
}
function HideAll() {
for (var i = 1; i < 4; i++)
document.getElementById('r ow' + i.toString()).display = 'none';
}
var to1,to2,to3;
// Stop Hiding From Old Browsers -—>
</SCRIPT>
<style type="text/css">
div {
border: 2px solid gray;
background-color: yellow;
}
.hide {
display: none;
position: relative;
}
.show {
display: inline;
}
</style>
</HEAD>
<BODY onmouseover="">
<CENTER>
<table border="1" width="300">
<tr><td onmouseover="to1 = ReadyForShowing('row1');"
onmouseout="StopShowing('r ow1', to1);">cory<div id="row1" class="hide">info about cory</div></td></tr>
<tr><td onmouseover="to2 = ReadyForShowing('row2');"
onmouseout="StopShowing('r ow2', to2);">jim<div id="row2" class="hide">info about jim</div></td></tr>
<tr><td onmouseover="to3 = ReadyForShowing('row3');"
onmouseout="StopShowing('r ow3', to3);">bob<div id="row3" class="hide">info about bob</div></td></tr>
</table>
</CENTER>
</BODY>
</HTML>
If you want, I can mark the places you'll need to make dynamic.
This works better. However, There's a lot of hard-coding involved (unfortunately), which can be tricky. Since you're using dynamic data (from a database), you'll have to change all hardcoded values (such as, like, looping from "row1" to "row3" you'll have to loop from "row1" to "row_" where _ is the total number of rows.
Let me know if this code works better for you:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Start hiding from old browser
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Eve
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
//document.Show.MouseX.val
//document.Show.MouseY.val
for (var i=1;i<4;i++) {
document.getElementById('r
document.getElementById('r
}
return true
}
function showit(on) {
var o = document.getElementById(on
o.style.position = 'absolute';
o.style.display = 'inline';
}
function hideit(on) {
var o = document.getElementById(on
o.style.display = 'none';
}
// timeout integers
function ReadyForShowing(the_row) {
var i = setTimeout("showit('" + the_row + "')",2000);
return i;
}
function StopShowing(the_row, the_to) {
clearTimeout(the_to);
hideit(the_row);
}
function HideAll() {
for (var i = 1; i < 4; i++)
document.getElementById('r
}
var to1,to2,to3;
// Stop Hiding From Old Browsers -—>
</SCRIPT>
<style type="text/css">
div {
border: 2px solid gray;
background-color: yellow;
}
.hide {
display: none;
position: relative;
}
.show {
display: inline;
}
</style>
</HEAD>
<BODY onmouseover="">
<CENTER>
<table border="1" width="300">
<tr><td onmouseover="to1 = ReadyForShowing('row1');"
onmouseout="StopShowing('r
<tr><td onmouseover="to2 = ReadyForShowing('row2');"
onmouseout="StopShowing('r
<tr><td onmouseover="to3 = ReadyForShowing('row3');"
onmouseout="StopShowing('r
</table>
</CENTER>
</BODY>
</HTML>
If you want, I can mark the places you'll need to make dynamic.
ASKER
thanks man, i should be able to figure out the dymanic stuff, i just say row(then my record unique id) and that seems to do the trick, i'm gonna mess w/ this, thanks again
ASKER
do I have to put a dynamic number after to as well?
ASKER
it seems to be working fine, however it doesn't move with the mouse after i put it in my code, the diff is i use the code on the TR tag so when they mouseover the row they would see it, also i get a javascript error at this line: document.getElementById('r ow' + i.toString()).style.pixelL eft = tempX+2;
but other than that its goin
but other than that its goin
ASKER