I've been searching all over the place to try and get my text field to clear after submit. Keep in mind that I want to stay on the same page when data is being submitted (I have a jquery code for staying on the same page after submission). I figured that it would be a lot easier if I just posted my code so that I can get help in my specific case. The following is what I tried, the .reset(), java onclick, onsubmit, jquery and ajax methods and none of them have produced the result that I am looking for. The closest I have gotten was a form getting cleared before submit and this leaves a blank submission.
Here's my form code for getting test info from the user. Here I tried the onclick, onsubmit methods without much luck:
<form id=\"msg\" method=\"post\" action=\"topage.php\" style=\"text-align: center; font-size: 26px; font-weight: bold; color: white; position: relative; top: -45px\">
MESSAGE<br><input type=\"text\" style=\"font-size: 22px;width:90%; height:50px; resize: none; \" name=\"msg\" >
<input class=\"submit\" type=\"submit\" value=\"Send\" style=\"width:90%; height: 40px; \">
<div id=\"message\"></div>
</form>
Here's my stay on page after submit code. I am using a script include to allow my stay on the same page after submit to work. It took me awhile to find a way to stay on same page after submit. If there is a better method for staying on the same page that works with clearing a form after submission by all means please share:
<script src=form.js></script>
<script type="text/javascript" >
$(document).ready(function() {
$('#msg').ajaxForm({
target: '#message',
success: function() {
$('#message').fadeIn('slow');
}
});
});
</script>
Aucun commentaire:
Enregistrer un commentaire