How to submit this form without using submit button. I want to submit it in loading this form,
<form name="frm1" id="frm1" action="../somePage" method="post">
Please Waite...
<input type="hidden" name="uname" id="uname" value="<?php echo $uname;?>" />
<input type="hidden" name="price" id="price" value="<?php echo $price;?>" />
</form>
After that add onload event to body. How to Submit Form Automatically On Page Load In JavaScript Below JavaScript code helps to submit form on load instead of clicking submit button. Use the Form name exactly, as it is used in the HTML page. XHTML <script language="javascript"> function onLoadSubmit() { document.nameofForm.submit(); } </script>
The Submit Button The <input type="submit"> defines a button for submitting the form data to a form-handler. The form-handler is typically a file on the server with a script for processing input data.
When this html form is submitted, it will call the javascript function yourJsFunction (), but it won’t reload the page. 2. Use jQuery’s submit event to handle the form submit, add return false; at the end of the submit handle function to prevent the page to reload.
Below JavaScript code helps to submit form on load instead of clicking submit button. Use the Form name exactly, as it is used in the HTML page. Add this onload function to body tag, we are executing onLoadSubmit function on page load. If you are not using this function, then this code won’t work. <body onload="onLoadSubmit ()"> <!--
You don't need Jquery here! The simplest solution here is (based on the answer from charles):
<html>
<body onload="document.frm1.submit()">
<form action="http://www.google.com" name="frm1">
<input type="hidden" name="q" value="Hello world" />
</form>
</body>
</html>
You can try also using below script
<html>
<head>
<script>
function load()
{
document.frm1.submit()
}
</script>
</head>
<body onload="load()">
<form action="http://www.google.com" id="frm1" name="frm1">
<input type="text" value="" />
</form>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With