This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clear all forms & struts

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Than do not use the formName. Use the forms array

var myForms = document.forms;

Eric
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic