offset top calculation problem

Giganews Newsgroups
Subject: offset top calculation problem
Posted by:  Michael Hill (hill…@ram.lmtas.lmco.com)
Date: Tue, 02 Sep 2003

If I have a button defined as:
<input type="button" name="zzz">

I can determine the top position using the function getOffsetTop below
like:
var tableTop = getOffsetTop(zzzz);                //and I get a valid
value

However if I have another function involved where the button name is
being passed to it I'm having a problem not knowing how to call this.

onclick=temp(zzzz);

function temp(mybutton)
    {
    var tableTop = getOffsetTop(mybutton);
    }

function getOffsetTop (el)
        {
        var ot = el.offsetTop;
        while ( ( el = el.offsetParent ) != null )
            {
            ot += el.offsetTop;
          }
          return ot;
        }

Replies