• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts: html:form name

 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some javascript on a page that is using some of the form fields. The script needs the name of the form to get access to the fields. I am having trouble giving a name to the html:form tag. If I put a name in the tag, it tells me I need a type. I have no idea on what type to put. Any ideas? Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
You declare an action attribute in your html:form tag. Struts looks up the name of the form based on your struts config file. So you can look there for the name to use in javascript.
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either way you can refer to the form like

document.forms[0]
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not quite sure what you mean, but you did inspire me to look at what the html:form looks like after it's rendered. (I'm rather embarrassed that I didn't think about that earlier.) Anyhow, Struts gives the html form the name of the defined action form class. So in my javascript I used that as the form name and voila, success. Thank you for responding!
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shankar Narayana:
Either way you can refer to the form like

document.forms[0]


Good point. I forgot all about that. Thanks.
[ August 05, 2004: Message edited by: Eric Sexton ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic