View Single Post
  #1 (permalink)  
Old August 22nd, 2003, 01:48 PM
JLJones13 JLJones13 is offline
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default OnChange Event Doesn't Execute

Hi All!

I have a form with a Readonly text field for a date.
When the user clicks on the field, or a calendar icon next to the field, a modal calendar pops-up.
Once the user clicks on a date in the calendar window, the date is inserted into the date text field.

When a date is inserted into the field, I want to call a function to populate an array of dates. However, my OnChange event is not firing.

I have tried placing the code in the OnBlur event, but it executes too often (once when the calendar pops up, next when the user chooses a date and gets back to the field, ...).
And, if I place it with the OnClick event, it causes the event to fire before the date has been entered.

How can I get the OnChange event to execute? Or, if there's a better way, please let me know ;o)

Here's an abbreviated version of the code. Let me know if you need more details...

Thanks in advance!

Code:
function OpenCalWindow(WindowTitle,TargetField){
    //date currently in targetfield
    var dtValue = frmRequest.all(TargetField).value;
    //use server current date rather than client
    var today = frmRequest.hidToday.value;        

    window.open("Includefiles/Cal.asp?target="+TargetField+"&title="+WindowTitle+"&dtValue="+dtValue+"&today="+today,"Calendar","width=200,height=200,resizable=no,scrollbars=no,top=50,left=50");

}


function CalcDate(){
    //Build an array of dates...
    //and set another field on the form to the last date of the array.
}


<input type="text" 
value name="calStartDate" 
size="10" 
readonly
onclick="javascript:document.frmRequest.howOften(0).checked=true;javascript:theLastDay.style.display='none';javascript:OpenCalWindow('Date','calStartDate')"
onchange="javascript:CalcDate()"
style="cursor:hand;" 
title="Click to show calendar">