• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

submitting a form and clearing it first

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form that contains a textarea. The data in the textarea is the contents of a log file that can get pretty lengthy. When I click on an <input="submit"> button in the form all of the data in the form gets sent to the server. I could care less for this to happen and would rather just clear the form so that all that data isn't passed to the server (also all the form data is displayed in the "Address" field of the browser window which I also want to avoid).
The way the form works is that a JavaBean call actually populates the textarea in the following way:

When the page is updated after the Refresh Log button is pressed the call to getSysLogData() will populate the textarea with the data that the bean gets out of a file. I just want to avoid sending all the data in the textarea to the server when the Refresh Log button is pressed since I don't care about it in the first place. I just want the page to update and make the call to the bean to get the data.
So how can I clear the form when the Refresh Log button is pressed before the actual "Submit" of the form takes place?
Lon Allen
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Put method="post" on your form tag to prevent the data from being passed as part of the URL.
2) Use the on_submit (remove underscore) handler to cause a JavaScript function to execute when the form is submitted. This function can manipulate the content of your form fields to your heart's content. Be sure to return true from your function.
Example:

(remove underscore)
hth,
bear
P.S. Returning false from the method prevents the form from being submitted and so is a good way to perform validation.
[ November 04, 2002: Message edited by: Bear Bibeault ]
 
Lon Allen
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear!
That was a lot of help.

Lon
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic