Results 1 to 2 of 2

Thread: checkbox coordinates

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    24

    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?

  2. #2
    Lively Member
    Join Date
    Jun 2003
    Posts
    83
    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
    - Steve

    "I'm glad I wore these pants."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width