Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Auto submit form after 5 seconds
I have a customer portlet, that I would like to auto submit a form in this portlet after x number of sceonds, let's say 5 for example. I have the below in my xhtml file;
the above seems to work, but it is not waitinf for 5 seconds. It is redirecting almost immediately. I can change the setTimeout call to be 60000, and it redirects immediately. Any suggestions?
Thanks!!
<form id="qrcodeRedirectForm" name="qrcodeRedirectForm" method="post" action="${formAction}">
<input type="hidden" name="qr_code_identifier" id="qr_code_identifier" value="${qr_code_identifier}">
<div class="enroll-button">
<p><input type="submit" value="Submit" class="inputButton"></p>
</div>
<noscript>
<p>
Please click the below button to go to the page you requested.
</p>
<p>
<input type="submit" value="Submit" class="inputButton">
</p>
</noscript>
</form>
<script type="text/javascript">
jQuery(document).ready(function() {
setTimeout(document.qrcodeRedirectForm.submit(),6000);
});
</script>
the above seems to work, but it is not waitinf for 5 seconds. It is redirecting almost immediately. I can change the setTimeout call to be 60000, and it redirects immediately. Any suggestions?
Thanks!!
Hi Jason,
Try
That is - remove the parens after submit. You're calling submit() when you're setting the timeout, when what you want to do is pass the submit function reference.
Try
setTimeout(document.qrcodeRedirectForm.submit,6000);That is - remove the parens after submit. You're calling submit() when you're setting the timeout, when what you want to do is pass the submit function reference.
I implemented your suggestion, but now page is not getting auto submitted at all.
I actually got this working using the below:
Thanks.
<script type="text/javascript">
window.onload=function(){
window.setTimeout('document.qrcodeRedirectForm.submit()', 500)
}
</script>
Thanks.
Community
Company
Feedback