PDA

View Full Version : aligning help


Kram
04-14-2004, 09:30 PM
The problem i am having is this.

I have a web page (which is an internal intranet site so cant post the address), which has menus, these menus are created by VBscript. The idea behind them is that a user of the web page can update/change menu headings/menu items by simply updating a text file.

That is not the problem, the issue here is that the menu items are dynamically changed quite often. Which means that the drop down menus position on the screen need to be changed often as well, which is a pain.

What I want to do is to be able to somehow calculate the position of the menus somehow using javascript.

Im just not sure how to do this.
help!

lukem
04-14-2004, 09:42 PM
Got anymore info? Why do the positions of the menus change? vertical or horizontal or both?

Kram
04-14-2004, 09:47 PM
Well luke, the menus change in width. for example:

[menu1][menu2][menu3][menu4]

this could be the layout of the menus at first. So the drop down menus pixel positions would be aligned to the correct place. but like i mentioned eariler the menus names can be changed, and will be.

so it could be changed to

[thefirstmenu][number2][3][menu4][somename]

which would obviously throw out the positioning of the dropdown menus

Ninkasi
04-14-2004, 10:27 PM
I thought you fixed this mark??

Kram
04-16-2004, 12:33 AM
for anyone that is interested:

a VERY simplifed version of the solution is below:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function getP(){
xpos = document.getElementById('tab').offsetLeft+document.getElementById('cell').offsetLeft;
ypos = document.getElementById('tab').offsetTop+document.getElementById('cell').offsetTop;
//alert('The cell has the coordinates X='+xpos+' Y='+ypos);
document.getElementById('div2').style.top = ypos+21;
document.getElementById('div2').style.left = xpos-1;

}

</script>
</head>

<body onload="javascript: getP();">
<table id="tab" border="1" width="100" cellpadding="0" cellspacing="0" align="center">
<tr id="cell">
<td>1</td>
<td bgcolor="#CCCCCC">2</td>
</tr>
</table>


<div id="div2" style="position:absolute; width:135px; height:45px; z-index:2;">
<table border="1">
<tr id="cell2">
<td bgcolor="lightblue">here i am</td>
</tr>
<tr>
<td>blah</td>
</tr>
</table>
</div>

</body>
</html>

Ninkasi
04-16-2004, 12:45 AM
Congrat Kramie! :D yay!!!

:cheers: :cheers: :cheers: :cheers: