I have a form which posts using ajax and reloads the div underneath.
I need the textbox to clear when the submit button is pressed.
<form name=goform action="" method=post>
<textarea name=comment></textarea>
<input type=submit value=submit>
</form>
I have a form which posts using ajax and reloads the div underneath.
I need the textbox to clear when the submit button is pressed.
<form name=goform action="" method=post>
<textarea name=comment></textarea>
<input type=submit value=submit>
</form>
Add an id for the textarea.
<textarea name='comment' id='comment'></textarea>
Hook into the submit process and add:
$('#comment').val('');
Simply call this after posting:
$("textarea[name=comment]").val("");
Or to improve, assign an ID to your textarea:
<form name=goform action="" method=post>
<textarea id="txtComment" name="comment"></textarea>
<input type=submit value=submit>
</form>
and use this after posting:
$("#txtComment").val("");
If you're not using jQuery (which is required for the solutions given above) you can replace the
$("#txtComment").val("");
with
document.getElementById("txtComment").value = "";