SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    finding the posision of a textbox

    Hello

    How I can find the posision of an object in a page ,
    I use offsetTop and Left but it can not work corectly in tables
    for example In the sample file show the left is 1 but ...


    link of sample : http://www.30too.com/sample.htm

  2. #2
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    who can help me ?

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will have to use CSS to position it, so you can get the location, something like this.

    I don't know is there's a better way.

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    HTML>
    <
    HEAD>
    <
    META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <
    TITLE>Untitled Page</TITLE>

    <
    SCRIPT TYPE="text/javascript">

            function 
    Pos() {

                     var 
    Top  document.getElementById("TheBox").style.top;
                     var 
    Left document.getElementById("TheBox").style.left;

                     
    alert("The Text box is in position: Top=" Top ", Left=" Left);

            }

    </SCRIPT>


    </HEAD>
    <BODY bgcolor="#FFFFFF" text="#000000">

    <INPUT ID="TheBox" type="text" style="position:absolute;left:140px;top:48px;width:184px;z-index:1" size="23" name="" 

    value="">

    <INPUT TYPE="BUTTON" VALUE="Get Position"  OnClick="Pos()">

    </BODY>
    </HTML> 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •