title: javascript close a popup on submit
body: <p>Ok.  I've seen this question as been unanswered for over 10 years..  </p>
  
  <p>How do you submit and close a popup in one button call.  </p>
  
  <p>suggestions run thus. </p>
  
  <pre><code>function saveNClose()
  {
    document.form.submit();
    self.close();
  }
  this doesn't work because the submit has a redirect, and the self.close is never reached.
  </code></pre>
  
  <hr>
  
  <pre><code>function closeLaterNSaveNow();
  {
    setTimeout("window.close()",5000);
    document.form.submit();
  }
  same problem..  the close is never called because the script for the page is gone.
  </code></pre>
  
  <hr>
  
  <pre><code>function closeNowNSubmit()
  {
    self.close(); 
   document.form.submit();
  }
  the window closes, but nothing gets saved.  server doesn't even get notified of anything..
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;input class='btn btn-success' disabled='disabled' id='SubmitFinal' onclick='closeWindow()' type='submit' value='Finish'&gt;
  Well then there's no validation of the data.  it submits before the function is called.
  </code></pre>
  
  <p>Anyone solve this?  I found the same solutions dating back to 2002, and some as recent as this month.  I shall continue to look, but I'm hoping someone has nailed it and that that someone answers here</p>