javascript - Automatic click Submit after 10 seconds in php -
this question has answer here:
- submit form jquery after delay 2 answers
here want happened html code.. have html code written in php code , want add java script(or can me) automatically submit form after 10 seconds.. creating examination system school , want time bounded.. code..
echo "<form action=\"posttest1.php\" method=\"post\">"; echo "<tr><td>"; echo $row['description'] . "<br>"; echo "<input type=\"radio\" name=\"answer\" value=\"a\"> a.)" . $row['ans1']; echo "<br>"; echo "<input type=\"radio\" name=\"answer\" value=\"b\"> b.)" . $row['ans2']; echo "<br>"; echo "<input type=\"radio\" name=\"answer\" value=\"c\"> c.)" . $row['ans3']; echo "<br>"; echo "<input type=\"radio\" name=\"answer\" value=\"d\"> d.)" . $row['ans4']; echo "<br>"; echo "<input type=\"submit\" value=\"submit\" name=\"submit\">"; echo "</td></tr>"; echo "</form>";
i wonder language can me.. either js or jq.. thankyou much! :)
using jquery settimeout()
<script type="text/javascript"> $(function(){ // document.ready function... settimeout(function(){ $('form').submit(); },10000); }); </script>
add inside head tag <head>
.. better add id form , use id selector $('#formid').submit();
updated
using form id specific..
echo "<form action=\"posttest1.php\" method=\"post\" id='formid'>"; .....
and
settimeout(function(){ $('#formid').submit(); },10000);
Comments
Post a Comment