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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read an element's position

Status
Not open for further replies.

fishiface

IS-IT--Management
Feb 24, 2003
687
GB
I'm trying to construct a tabbed dialogue to handle large and complex submission forms. The javascript is to be generated on the fly by a perl module which is passed the required HTML for each tab as it's parameters.

My first attempt used a div element and wrote the relevant HTML chunks to the div's innerhtml property. Although this looked great, the form fields would not retain value or post. I looked at palbano's answer to PoppapumpJ's question in thread 510405 and now understand why but, to use his technique, I would need to be able to convert arbitrary HTML into the correct series of [tt]createElement()[/tt] and [tt]setAttribute()[/tt] calls. This solution seems disproportionally complex.

I have seen another type of solution using ilayers where the tab controls set the visibility of the various ilayers. This would seem to get around the "dynamically created element won't post" problem but introduces a further problem.

The ilayers need to occupy the same space on screen in order to work correctly. In every example that I have seen, the postitions of the various ilayers are set to "absolute" and then set to literal values. I can't do this as I have no control over where my module is called - it's output could end up anywhere in the browser's window as part of a more complex page.

Is it possible to draw the first, visible ilayer wherever it lands (with it's position set to "relative") and then read it's position variables?. I could then set these values as the position for subsequent ilayers to get the required overlap - maybe in the body [tt]onLoad[/tt] element.

Alternatively, if I'm missing another obvious approach, I would be grateful for suggestions.

Yours,

Is it possible to "As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
HTMLElement.offsetLeft
HTMLElement.offsetTop

should give you the x and y position of an element on the screen. works for the DOM browsers I use...NS 7, Phoenix 0.5, Moz 1.3, IE 6



=========================================================
while (!succeed) try();
-jeff
 
Thanks jeff: I'm on IE6 and it's intranet stuff (control over browser choice!) so I'll give that a shot.

PS

Code:
trap 2,3,4,5,6,7,8,9,10,11,12,13,14,15 goto $pub
while(!succeed) try();
"As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilk
 
yep - i get to code for an IE intranet too...makes for some handy options with the built in IE dhtml stuff, but i also try to keep things DOM for the challenge.

is this unix?
"trap 2,3,4,5,6,7,8,9,10,11,12,13,14,15 goto $pub"

=========================================================
while (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top