Solved

onChangeEvent not firing after onContextChange event

Posted on 2004-10-05
4
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Suggested Courses

751 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