Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Submitting Input fields in struts

 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic