Log in

View Full Version : Button to clear Textarea



julmado
07-10-2006, 01:58 PM
How can I make a button to clear just the <textarea>?

shachi
07-10-2006, 03:51 PM
It's really simple:



<form action="someplace.php" method="POST" name="form">
Name: <input type="text" name="input" id="input" class="input">
Email: <input type="text" name="email" id="email" class="email">
Comment:<textarea name="comment" id="comment" class="comment"></textarea>
<input type="button" value="Reset" onclick="document.form.comment.value=''">
</form>


Hope that does it!!

Twey
07-10-2006, 03:53 PM
Actually, it's even simpler:
<form action="someplace.php" method="post">
<label>Name: <input type="text" name="input" id="input" class="input"></label>
<label>Email: <input type="text" name="email" id="email" class="email"></label>
<label>
Comment:<textarea name="comment" class="comment"></textarea>
<input type="button" value="Reset" onclick="this.form.elements['comment'].value=''">
</label>
</form>

julmado
07-12-2006, 03:35 AM
Works like a charm. Many thanks!