Hello-

I have a script that calculates the (x,y) coordinates of an input html element. The reason why I need to do this is because IE is not displaying the popup calendar in the proper position. I am using the DHTML calendar widget. I am able to get the (x,y) locations but my issue is passing these values to the Calendar.setup() javascript function. Here is the code that calculates the (x,y) values:
Code:
function getPos()
{
var elementToFind = document.getElementById('cancelTrigger');
var elementLocs = findPos(elementToFind);
var result = document.getElementById('location').value = ('[' + elementLocs + ']');
}

function findPos(obj)
{
var curleft = curtop = 0;
if(obj.offsetParent)
{
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while(obj = obj.offsetParent)
{
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}
return [curleft, curtop];
}
Here is my form script that calls these functions:
Code:
<tr>
<td colspan="*" valign="bottom">
<input type="text" name="future_cancel_date" value="" id="futureCancelDate" readonly="1">&nbsp;
<img src="/images-system/ico_date.gif" border="0" id="cancelTrigger" style="cursor: pointer;" title="Date selector" onClick="getPos();">
&nbsp;<a href="#" onclick="javascript:document.cancelform.future_cancel_date.value=''"><?= $langContent[$section]['clear_cancellation_date'] ?></a>
<input type="hidden" id="location">
</td>
</tr>
Here is the script that displays the popup calendar:
Code:
<script type="text/javascript">
Calendar.setup({
inputField     :    "futureCancelDate",    	// id of the input field
ifFormat       :    "<?= str_replace(array('Y', 'y', 'm', 'd'), array('%Y', '%y', '%m', '%d'), $locale->getDateFormat()) ?>",      	// format of the input field
button         :    "cancelTrigger",  	// trigger for the calendar (button ID)
singleClick    :    true,
position       :    document.getElementById('location').value;
});
	
</script>
This is not working because the (x,y) is 152, 722 and if I put it in staticly as position : [152,722], it displays right where I need it to be. I hope this is not too confusing. Much appreciation. AM