Results 1 to 4 of 4

Thread: Button to clear Textarea

  1. #1
    Join Date
    Sep 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Button to clear Textarea

    How can I make a button to clear just the <textarea>?

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's really simple:

    Code:
    <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!!

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Actually, it's even simpler:
    Code:
    <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>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Sep 2005
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Works like a charm. Many thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •