| Author |
Accessing the Struts form object in JavaScript
|
M Burke
Ranch Hand
Joined: Jun 25, 2004
Posts: 375
|
|
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>
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
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
|
Merrill
Consultant, Sima Solutions
|
 |
M Burke
Ranch Hand
Joined: Jun 25, 2004
Posts: 375
|
|
That worked, thanks for the insight Merrill
|
 |
 |
|
|
subject: Accessing the Struts form object in JavaScript
|
|
|