Calendar Date-Picker can't find date field (X,Y)

Discussion in 'Javascript' started by randomblink@yahoo.com, Jan 3, 2005.

  1. Guest

    Alright...
    I have a calendar date-picker. When you click in certain fields (date
    fields I created in my HTML), what is supposed to happen is this
    calendar pops up right beside the date field... You select a date and
    it drops it into the date-field. Well, it works JUST fine... EXCEPT...

    Inside my form...
    I have <table> tags to separate the different pieces of the form from
    each other.
    So my form looks like...

    <form blah blah>
    <table id="this_section" style="display:none;">
    <tr><td>blah blah blah</td></tr>
    </table>
    <table id="now_this_section" style="display:none;">
    <tr><td>blah blah blah</td></tr>
    </table>
    </form>

    Then on the same page I have buttons you press to make those sections
    of the form VISIBLE.

    Here comes my problem...
    I have like 8 sections to this form... I do NOT want to break it up to
    different pages... I WANT to stick with this format... BUT whenever I
    make an INVISIBLE table appear, the calendar won't appear beside that
    sections date field IF those date-fields were originally below the
    screen height...

    The code I use to FIND the Date-Field is:
    // get X coords of obj
    function findPosX(obj)
    {
    var curleft = 0;
    if (obj.offsetParent)
    {
    while (obj.offsetParent)
    {
    curleft += obj.offsetLeft
    obj = obj.offsetParent;
    }
    }
    else if (obj.x)
    curleft += obj.x;
    return curleft;
    }

    // get Y coords of obj
    function findPosY(obj)
    {
    var curtop = 0;
    if (obj.offsetParent)
    {
    while (obj.offsetParent)
    {
    curtop += obj.offsetTop
    obj = obj.offsetParent;
    }
    }
    else if (obj.y)
    curtop += obj.y;
    return curtop;
    }

    function getElementPosition(elemID)
    {
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = findPosX( document.getElementById( elemID ) );
    var offsetTop = findPosY( document.getElementById( elemID ) );
    var WinHeight = getInsideWindowHeight();

    if ( offsetTop > WinHeight )
    {
    var offsetTop = WinHeight - offsetTop;
    return {left:eek:ffsetLeft, top:eek:ffsetTop};
    }

    // commented out because it isn't working either...
    // 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:eek:ffsetLeft, top:eek:ffsetTop};
    }

    function showCalendar(evt)
    {
    evt = (evt) ? evt : event;
    if (evt)
    {
    if (document.getElementById("calendar").style.visibility !=
    "visible")
    {
    var elem = (evt.target) ? evt.target : evt.srcElement;
    document.getElementById("fieldSelector").value = elem.id;
    var position = getElementPosition(elem.id);
    shiftTo("calendar", position.left + elem.offsetWidth, position.top
    );
    show("calendar");
    }
    else
    {
    hide("calendar");
    }
    }
    }



    Can someone help me?
     
    , Jan 3, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shevek
    Replies:
    3
    Views:
    6,122
    Shevek
    Jun 23, 2004
  2. TB
    Replies:
    0
    Views:
    478
  3. bala2008
    Replies:
    0
    Views:
    660
    bala2008
    Jun 27, 2008
  4. sgMuser
    Replies:
    0
    Views:
    358
    sgMuser
    Jun 12, 2006
  5. Pooley
    Replies:
    1
    Views:
    84
    Triar
    Jan 23, 2007
Loading...

Share This Page