I'm facing an issue with submitting a form after the page loads and 5 seconds have passed. I've tried using setTimeout but it doesn't seem to be working. Can anyone suggest why this might be happening? jQuery and delay() also don't work on the site.
<form action="" name="cartCheckout" id="cartCheckout" method="post">
<input type="hidden" name="action" value="checkout" />
<input type="hidden" name="save" value="1" />
<input type="hidden" name="orderID" value="<?php echo $GLOBALS['CHECKOUT_ORDERID']; ?>" />
<div class="itembox" id="step4box">
<div id="progress">
<ul>
<li>Your Cart</li>
<li>Your Details</li>
<li class="current">Payment</li>
<li>Confirmation</li>
</ul>
</div>
<div id="words" class="gothbold">Please wait while we redirect you to<br />Paypal for a secure payment method.</div>
<a class="redirect" href="javascript:void(0)" title="Proceed to Paypal" onClick="document.cartCheckout.submit();"><span>If you aren't redirected in 5 seconds click here</span></a><br />
<a class="cancel" href="javascript:void(0)" title="Return to details" onClick="jQuery('#step4box').hide();jQuery('#step2box').show();"><span>Cancel</span></a>
</div>
<script type="text/javascript">
window.onload=function(){
window.setTimeout(document.cartCheckout.submit(), 5000);
};
</script>
</form>
Any assistance would be highly appreciated, thank you!
EDIT:
This has now been fixed by combining suggestions from @Alex, @user824294, and another solution found in this question: How Can I create A 5 second Countdown timer with jquery that ends with a login popup?. The countdown functionality works great now. Thank you all!
window.onload=function(){
var counter = 5;
var interval = setInterval(function() {
counter--;
$("#seconds").text(counter);
if (counter == 0) {
redirect();
clearInterval(interval);
}
}, 1000);
};
function redirect() {
document.checkout_paypal.submit();
}