SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    louisiana
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reset form field when form submitted to frame

    I'm not very good at javascript yet, but it seems like there should be a way to do this. Am creating a framed chat application and when the user types a message in the form field and clicks the submit button, the message gets sent to the display frame, but the message stays in the form field. How can i get the form to submit the message AND reset the form field to blank too?

  2. #2
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if document.getElementById("formname").reset(); will work, but if it doesn't try this:

    Code:
     function EmptyFields() {
      document.getElementById("formfield1").value = '';
      document.getElementById("formfield2").value = '';
      // And so on....
     }
    
     <form onsubmit="EmptyFields();">
    - Saj


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
  •