title: How to delay form submit?
body: <p>I have a form that once the user clicks the Submit button - it runs 2 functions - (1) it pops up with a div that says 'Item added successfully to basket' then (2) a prefill function that sends the selected options to a Mals-E cart.</p>
  
  <p>It works, but what i need to do is not let the form submit until the popup has shown for around 5 seconds - currently it flashes for a split second as the form is submitted immediately with the prefill function.</p>
  
  <p>Can anyone help with this please?</p>
  
  <p>Script Below:</p>
  
  <pre><code>function showDiv(f) {   
      document.getElementById('basket-center').style.display='block';
  }   
  
  function prefill(f) {
  
      var val = document.forms["basket"].elements["product[2]"].value;
      val = val + gettext(document.forms["form"].elements['users']);
      document.forms["basket"].elements["product[2]"].value = val;
  
      document.forms["basket"].elements["price"].value = document.forms["form"].elements['sum'].value;
  
      return false;
  }
  </code></pre>
  
  <p>Form Script Here:</p>
  
  <pre><code>&lt;form id="basket" name="basket" action="http://ww8.aitsafe.com/cf/add.cfm" method="post" onsubmit="showDiv(); prefill();"&gt;
      &lt;input name="userid" type="hidden" value="A1251773"/&gt;
      &lt;input type="hidden" name="nocart"/&gt;
      &lt;input name="product[]" type="hidden" value="{b}Sage 50 Accounts (The VAT Edition) 2014{/b}"/&gt;
      &lt;input name="product[2]" type="hidden" value="{br}"/&gt;
      &lt;input name="product[3]" type="hidden" value="{br}FREE Installation onto 1 Server/PC &amp; Same Day Download when ordered before 3pm"/&gt;
      &lt;input name="price" type="hidden" value=""/&gt;
      &lt;input name="noqty" type="hidden" value="1"/&gt;
      &lt;input name="thumb" type="hidden" value="sage50-thumb.png"/&gt;
      &lt;input name="return" type="hidden" value="http://10.10.0.195/reality-solutions-development/sage-50-accounts.php"/&gt;
      &lt;input type="image" src="img/buynow-button-green.jpg" border="0" alt="Buy Now" style="float:right; margin-top:-24px"/&gt; 
  &lt;/form&gt;
  </code></pre>