Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Accessing the Struts form object in JavaScript

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Struts form and a Struts submit button. I also am using a third party JavaScript based date combo box with its own validation. I need to pass the form object to the date script so it can render the combo boxes at startup. The problem is, I know how to access a form object in regular html (this.formName), but how do I do it if Struts is controlling the form?

Code...
<html:form action="searchResults.do">

<!--Date--><SCRIPT>fill_select_from(this.SearchForm);year_install_from(this.SearchForm);</script>

<br><html:submit>Search</html:submit>
</html:form>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The important thing to remember is that struts tags are always rendered to regular html tags before they are displayed.

If you wish to write javascript to manipulate a jsp page created with struts custom tags, the best way to do it is to make frequent use of the "view source" function of your browser. In IE, you just right-click the frame you're in and select "view source" from the context menu.

Once you look at the "View Source" output, you will then see the actual html that was redered by your struts tags. You will then know how to write the javascript to access those html controls because you will know how struts has named them.

Merrill
 
M Burke
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That worked, thanks for the insight Merrill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic