Solved

onChangeEvent not firing after onContextChange event

Posted on 2004-10-05
4
220 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

770 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