title: Javascript event synchronisation
body: <p>Is there a possible way to synchronize events in javascript?</p>
  
  <p>My situation is following: I have a input form with many fields, each of them has a onchange event registered. there is also a button to open a popup for some other/special things to do in there.</p>
  
  <p>My requirement is, that the onchange event(s) are finished before I can open the popup.</p>
  
  <p>Any ideas how I can achieve that without using setTimeout?</p>
  
  <p><em>EDIT:</em> further explanation of requirements:</p>
  
  <p>To clarify my situation I try to detail what I'm doing.</p>
  
  <p>I got a form with some input items (order entry matrix form, e.g. article, serial#, count). Every time user changes data in one of the fields an ajax call is triggered by an onchange event to validate the user input and read additional data (e.g. presetting/formating one of the other fields). These ajax calls are heavy and cost time, so I have to avoid duplicate validations.
  There is also a button which opens a popup which gives the user an other form to change data he entered before line by line, so it is absolutely necessary that all validations are done before this popup is opened.
  At the moment I try to synchronize the onchange events and the popup opening using setTimeout (popup isn't opened before all validations are done), which causes problems at my customers site because these popups are trapped by the popup blocker.
  So I need to open my popups without getting stopped by some popup blocker (IE 6/7/8).</p>
  
  <p>Because of my matrix-form I just can't validate all input items before opening the popup, I need to validate only those which have been changed and are not validated yet (should be at most 1).</p>