onChangeEvent not firing after onContextChange event

Experts,

I have a Date input field which activates a calander which is used for populating the date. However, there is an issue:

When the onContextMenu event on the field is activated via the Right Mouse Click, the date field gets populated but the onChange event for the same field does not get fired. BUT, when I manually change the date and tab, then the onChange event does fire.

One thing I have noticed is that when the field gets populated via the calender, the focus is still not on the field itself, which is probably the cause of the issue, but I am not sure how to correct this. Below is how the tag looks.

<input type="text" name="DT_BGN" maxlength="10" size="10" tabindex="0" value="00/00/0000"onclick="this.select()" onchange="changes();processRemovalDate();" size="10" maxlength="10" onfocus="editMask(this);" onblur="editMask(this);" onkeypress="editMask(this);"  oncontextmenu="event.returnValue=false;event.cancelBubble=true;oPopup.hide();oPopupError;showCalendar(this.name, 'mm/dd/y');" onfocus="try
{
setReferenceToFocussedField(this);
} catch (e){
;
}" class="dateRequired">

Any help will be appreciated.

Thanks
gvijay1Asked:
Who is Participating?
 
ZvonkoSystems architectCommented:
when context event is fired is the field value not set. The value is set trilion miliseconds later when the user clicks on a calendar date.
0
 
ZvonkoSystems architectCommented:
That is because the field value is not set by user but by script.
Therefore you have to call the onchange event also from the script.
Therefore you have to look at your showCalendar() function where the field value is returned to the target field.
After the value is set to the field by script you can do this onchange call:
theField.onchange();

Because the field is passed as string name to the showCalendar() function does perhaps the field reference looks like this:
document.forms[0][fieldName].onchange();

If you show here the calendar script, then we can elaborate the onchange() statement for you.

0
 
gvijay1Author Commented:
Actually, following the above question: would it also be possible to "chain" two events in javascript.

For example, when the context menu event is fired, I will manually fire the onChange event, but I only want the second event to start once the first one has completed executing.

If so, I can think of a workaround for this issue.
0
 
ZvonkoSystems architectCommented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.