Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Clear Form Button

  1. #1
    Join Date
    Jul 2005
    Location
    Planet Earth
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Clear Form Button

    HI,

    How does one make a button or link for a form so that it clears
    text entered in a form?

    Redice

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

    Default

    <input type="reset"/>
    Make sure it's inside the desired <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!

  3. #3
    Join Date
    Jul 2005
    Location
    Planet Earth
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks twey

    how bout when wanting to apply it to an image?
    Maybe I could upload the page for you to have a look, and also let me know how I could apply a mail form script to my form! Is that OK?

    Redice

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

    Default

    HTML Code:
    <form id="form1">
    <input type="text"/>
    <input type="text"/>
    <input type="password"/>
    <input type="text"/>
    </form>
    <img src="image.jpg" onclick="document.getElementById('form1').reset();"/>
    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!

  5. #5
    Join Date
    Jul 2005
    Location
    Planet Earth
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the code works well. thnx
    but when i put the cursor over the image in the browser
    the cursor doesnt change. Isnt it ment to?

    redice

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

    Default

    No. If you want it to, you can use:
    <img src="image.jpg" onclick="document.getElementById('form1').reset();" style="cursor:pointer"/>
    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!

  7. #7
    Join Date
    Jul 2005
    Location
    Planet Earth
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    how do i make text and image as submit button? For the form?

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

    Default

    You can add onclick="document.getElementById('form1').reset();" to any element: <span>, <img>, <p>, <a>...
    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!

  9. #9
    Join Date
    Jul 2005
    Location
    Planet Earth
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi all,

    Back at this!! I got the clear to work fine.
    how do i get the submit/send button to work?

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

    Default

    Exactly the same as reset, but you use submit() instead of reset().
    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!

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
  •