wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes clear all forms & struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "clear all forms & struts" Watch "clear all forms & struts" New topic
Author

clear all forms & struts

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hello
How do I loop through and assign "" to all INPUT TYPE=text elements of all the forms on a document? I can see the document.form array, however I cant see how to set up the loop and specify only INPUT TYPE=text elements.

For deployment I will do this ins Struts and use the StyleId that should free me from any naming problems, but can this be integrated with the script achieving the above tia.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Can't you just use document.formName.reset(); ?

var elems = document.formName.elements;

alert(elems[0].type + "|" + elems[0].value);

Eric
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hi
I am trying to learn the DOM model better and I dont want to specify the exact formName. I want understand how to loop through the array of forms w/o specifying the exact number. Then loop through the html INPUT elements on the particular form specifying only the TYPE=text and assign them "".

The final aspect it to deploy this in Struts, but I think I can do that with EL on the code tag. Welcome comment on any/all. tia.
Originally posted by Eric Pascarello:
Can't you just use document.formName.reset(); ?

var elems = document.formName.elements;

alert(elems[0].type + "|" + elems[0].value);

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61090
    
  66

Originally posted by Chris Pat:

The final aspect it to deploy this in Struts, but I think I can do that with EL on the code tag.


That would be acompletely different mechanism than you are talking here. Javascript executues on the client after the page is loaded, JSP executes on the server to create the HTML page to send to the client.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hi
Okay then I will have to directionlessly figure out the js. However can someone tell me now to use the bean age to get and the bean:write tag to output to as a tag in html any of ServletContext, ServletConfig,etc. tia.
Originally posted by Bear Bibeault:


That would be acompletely different mechanism than you are talking here. Javascript executues on the client after the page is loaded, JSP executes on the server to create the HTML page to send to the client.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Than do not use the formName. Use the forms array

var myForms = document.forms;

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clear all forms & struts