wood burning stoves 2.0*
The moose likes Struts and the fly likes Submitting Input fields in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Submitting Input fields in struts" Watch "Submitting Input fields in struts" New topic
Author

Submitting Input fields in struts

meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
I have qustion on submitting the input fields to the form in Struts.

if we have a checkbox,a textbox and a submit button. and if we need to send the values typed in the textbox when the submit button is clicked, we normally place these input fields within html:form tags

example:

<html:form action="something.do">
<input type="text" name="txtbox" value=""/>
<html:submit styleId="btnSubmit>Submit</html:submit>
</html:form>

Is there a way in which we don't place them within html:form and still submit the text box value when the button is clicked?


I am aksing this question because, my jsp page does different things for different kind of buttons, but for position sakes they should be aligned together, but because of html:form tag, i am not able to place them in the positions i need
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
this is not a struts limitation/issue, but an HTML restriction. form elements must be encapsulated INSIDE the form tag to be submitted with the form.

one (insane) way to do this is use javascript. put your input field into a secondary form all by itself. put a hidden field in your primary form. onsubmit() of your primary form use javascript to grab the value from the secondary form and set the primary form's hidden field's value to that value.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Submitting Input fields in struts