Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table data reference and position

Status
Not open for further replies.

IBACFII

Programmer
Sep 2, 2004
76
US
Please help I need to allow my dynamically built menu to appear after the next <td></td> tags. I can find the current position of my cell that calls the menu however i cannot get it to be in the proper place ie more pixs to the left in one
 
Is relative position possible? Some code?

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
Thanks for the reply. However, I figured that I could dynamically add a character to the begining of the ID for the td tag and then reference it with the charAt() function. This allowed me to use a simple if statement to say if it was a certain char then add or subtract as necessary from the proper cordinates. IE
Code:
function mh_showmenu(caller)
    {
     var posi;
     var initcaller;
     var strcaller;
     var rpttype;
     initalCaller=caller;
     rpttype=initalCaller.charAt(0);

     posi=getAnchorPosition(caller);
     document.all.mh_menu.style.posTop=posi.y;
     if (rpttype=="F")
     {
     document.all.mh_menu.style.posLeft=posi.x+255;
     document.all.mh_menu.style.visibility="visible";
     }
     else if (rpttype=="X")
	{
	document.all.mh_menu.style.posLeft=posi.x-100;
	document.all.mh_menu.style.visibility="visible";
	}
     else
	{
	document.all.mh_menu.style.posLeft=posi.x+150;
	document.all.mh_menu.style.visibility="visible";
	}
     holder=1;
     return initalCaller;
     }


Thanks again for the repy
 
Thanks for the reply. However, I figured that I could dynamically add a character to the begining of the ID for the td tag and then reference it with the charAt() function. This allowed me to use a simple if statement to say if it was a certain char then add or subtract as necessary from the proper cordinates. IE
Code:
function mh_showmenu(caller)
    {
     var posi;
     var initcaller;
     var strcaller;
     var rpttype;
     initalCaller=caller;
     rpttype=initalCaller.charAt(0);

     posi=getAnchorPosition(caller);
     document.all.mh_menu.style.posTop=posi.y;
     if (rpttype=="F")
     {
     document.all.mh_menu.style.posLeft=posi.x+255;
     document.all.mh_menu.style.visibility="visible";
     }
     else if (rpttype=="X")
	{
	document.all.mh_menu.style.posLeft=posi.x-100;
	document.all.mh_menu.style.visibility="visible";
	}
     else
	{
	document.all.mh_menu.style.posLeft=posi.x+150;
	document.all.mh_menu.style.visibility="visible";
	}
     holder=1;
     return initalCaller;
     }


Thanks again for the reply
 
Are you looking for something like this (I didn't write it, can't remember where I dug it up)
Code:
function getElementPosition(elem) {
    var offsetTrail = elem;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 &&
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakespearean sonnet.
 
This is close to the way that i found it some where too. Except it uses some other functions. Funny how a person can usually solve the problem with enough time and references
Later.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top