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

R

randomblink

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top