I submit the form using simple ajax and return the results in a div above the form. The problem is that after the form is submitted and confirmed, I show thanks and want to reset the form so that they do not just press the submit button again ... It seems that they did not find the correct code ...
<form id="myForm" target="sendemail.php" method="post"> <div id="results"></div> <input type="text" name="value1"> <input type="text" name="value2"> <input type="submit" name="submit"> </form>
So, my sendemail.php validation errors and corrections appear in #results without problems.
But ... when I try to send the javascript form reset command, it does not work. Naturally, I do not see it in the source code, since it is an AJAX callback, so I do not know if this is a problem or I just use the wrong syntax.
echo "<p>Thank you. Your message has been accepted for delivery.</p>"; echo "<script type=\"text/javascript\">setTimeout('document.getElementById('myForm').reset();',1000);</script>";
Any guru ideas?
source share