• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts: html:form name

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic