aspose file tools*
The moose likes Struts and the fly likes Struts: html:form name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts: html:form name" Watch "Struts: html:form name" New topic
Author

Struts: html:form name

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
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

Joined: May 26, 2003
Posts: 30766
    
156

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Shankar Narayana
Ranch Hand

Joined: Jan 08, 2003
Posts: 134
Either way you can refer to the form like

document.forms[0]


"Failure is not when you fall down; its only when you fail to get up again."
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
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

Joined: Sep 12, 2003
Posts: 133
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts: html:form name