Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Currently I have two textboxes for date calendar. There is an img attached to display calendar icon. We have a javascript function in a js file to display date calendar.
Functions are written on the onoFocus event of text box:

<input type="text" maxlength="10" name="availableFrom" id="availableFrom" style="width:75px;" value="" onkeypress="return false;" onfocus="fn_displayDateSelection('availableFrom');">

Problem is that when I click on textbox or image to load the calendar it takes lot of time or does not load. However sometimes it works fine.

Please advise any solution to this.

Thanks,
Chandra
Posted
Comments
Sergey Alexandrovich Kryukov 16-Apr-15 13:04pm    
It depends on what fn_displayDateSelection does :-)...
—SA
chandrayog.2 21-Apr-15 7:11am    
here is the script:

function fn_displayDateSelection(_dateObj, _secondDateObj, _returnFunc) {
dt_displayTimeout = window.setTimeout('fn_hideDateSelection()', 30000);
if (!_returnFunc) { _returnFunc = ""; }

dt_selectedField = document.getElementById(_dateObj);
dt_secondDateField = (_secondDateObj) ? document.getElementById(_secondDateObj) : null;

try {
var thisDate = formatDateForSubmission($("#" + _dateObj).val(), dateFormat, "d¬/¬m¬/¬y");
var scrollTop = ($("#mainNavigationOffset").length > 0 && document.location.href.split("?")[0].split("/").pop().toLowerCase() != "xyzform.asp") ? $("#mainNavigationOffset").scrollTop() : 0;
var pos = $("#" + _dateObj).offset();
var top = 8 + pos.top + $("#" + _dateObj).height() + scrollTop;
var cHeight = $("#calendarFrame").height();

if (((top + cHeight) - scrollTop) > $(window).height()) {
top = top - cHeight - 20;
}

//show the menu directly over the placeholder
$("#calendarFrame").css({
position: 'absolute',
zIndex: 5000,
left: (pos.left) + "px",
top: top + "px"

}).attr("src", "../calendar.aspx?date=" + thisDate + "&returnFunc=" + _returnFunc);

$("#calendarFrame").hide().fadeIn();

} catch (er) {
alert("An error has occurred displaying date selection.\n" + er.description);
}
}
Sergey Alexandrovich Kryukov 21-Apr-15 9:24am    
Will you click "Improve question" and move the code to the question, where it belongs? You can format it there to make readable.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900