File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Submitting Input fields in struts" Watch "Submitting Input fields in struts" New topic

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


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

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="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Submitting Input fields in struts
It's not a secret anymore!