-
checkbox coordinates
Im trying to display a floating layer that could move beside a series of checkboxes. I can move the layer and change the text with no problem but I dont know what the coordinates are to move it to.
Im using this:
<A HREF="#" onClick="
document.all('Divfloat').innerHTML = '$desc';
Divfloat.style.visibility='visible';
Divfloat.style.left='200';" >...</A>
that sets the properties of the layer but I cant figure out how to get the coordinate for the top of a checkbox that it supposed to be near.
I was thinking something like this but I cant get it to work
Divfloat.style.top=document.All.item("checkbox1").offsettop;
Does anyone know how to get the coordinate of an object like a checkbox so I can use it to make something move beside it?
-
Code:
function getTopCoords(id) {
var obj = document.getElementById(id);
var posY = obj.offsetTop + obj.offsetHeight;
while (obj.offsetParent) {
obj = obj.offsetParent;
posY += obj.offsetTop;
}
return posY;
}
where id is the id of the checkbox