PHP, HTML: Submit form automatically -
i have php page html form on it. if variables set in url automatically submit form on page.
ie:
if (isset($_get['var'])) { // submit form } else { // leave page alone }
edit:
here have using answer provided below, it's still not working. form submit if condition met.
<?php if ($r == 1) { echo " <br> <form action=\"bookroom.php\" method=\"post\" id=\"dateform\"> <input name=\"from\" type=\"hidden\" value=\"$fday/$fmonth/$fyear\"> <input name=\"to\" type=\"hidden\" value=\"$tday/$tmonth/$tyear\"> <input type=\"submit\"> </form> <script type=\"text/javascript\"> $('#dateform').submit(); </script> "; } ?>
using pure javascript instead of jquery :
<?php if (isset($_get['var'])) {?> <script type="text/javascript"> document.getelementbyid('dateform').submit(); // submit form </script> <?php } else { // leave page alone } ?>
Comments
Post a Comment