[Javascript] Thoughts on building form elements/similar divs

Paul Novitski paul at novitskisoftware.com
Thu Jul 28 22:17:08 CDT 2005


At 11:45 AM 7/8/2005, Glenn E. Lanier, II wrote:
> > From: Paul Novitski
> > Sent: Wednesday, July 06, 2005 7:12 PM
>
> >          <div id="lists">
> >                  <input type="text" id="text1" />
> >                  <input type="text" id="text2" />
> >                  ...
> >          </div>
>
> >     - For each "input" tagName within container "lists":
> >        - Set style.visibility to hidden.
> >        - Set the onfocus function.
> >        - Perhaps record left & top coordinates in an array?
>
>So, how can I get the top and left coordinates of a single item?

Glenn,

You can determine the top & left of an object by cumulatively adding the 
.offsetTop and .offsetLeft of the object, it's parent, it's grandparent, 
and so on until you reach the "ceiling" (no more parents).  I figured this 
out and wrote functions that worked, but Peter-Paul Koch's functions are 
better and more sparely written:
http://www.quirksmode.org/js/findpos.html

Paul

(Sorry for the late reply; I overlooked your email amidst the incoming 
flood...) 





More information about the Javascript mailing list