Solved

onChangeEvent not firing after onContextChange event

Posted on 2004-10-05
4
218 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:gvijay1
  • 3
4 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 12232732
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
 

Author Comment

by:gvijay1
ID: 12232733
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
 
LVL 63

Accepted Solution

by:
Zvonko earned 75 total points
ID: 12232749
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
 
LVL 63

Expert Comment

by:Zvonko
ID: 12238449
Thanks.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now