Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling action with two nested forms

 
Mike Payton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have two nested froms calling the same action?

Is it possible ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. That would not be valid HTML markup.
 
Mike Payton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What possible option I can have to obtain this
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That very much depends on what you are trying to accomplish. What's your actual goal?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and Welcome to JavaRanch Mike Payton :)
 
Mike Payton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an if condition, Based on that I need to generate a popup for printing some PDFs.

Here is the code

<HTML:form action="action.do" >
<% if(condition()) {%>
<span>
<input type="button" onclick="javascript:cancel1()" property="" Class = "bSwan" tabindex="7" value="Cancel" />
<input type="button" id="submit" property="" Class = "bSwan" tabindex="7" value="save" />
<div id="pay_dialog" title="Dialog Title">

<form id="auth_form">
<input type="button" value="Print Authorization Form" id="printpdf" property="" Class = "bSwan" tabindex="7" />
<input type="submit" value="Submit" id="submit_form" property="" Class = "bSwan" tabindex="7" />
</form>
</div>
</span>
<%}else{%>
<span>
<input type="button" onclick="javascript:cancel1()" property="" Class = "bSwan" tabindex="7" value="Cancel" />


<html:submit property="" styleClass = "bSwan" onclick="" tabindex="7">
<bean:message key="global.button.Save" />
</html:submit>
</span>
<% } %>

</HTML:form>


Can I have <form id="auth_form" action="action.do"> ?

I mean in both the condition I need the same value on form to be submitted to the same action.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AH, you are using Struts. I'll move this over to he Struts forum.

You can have as many forms as you want, you just cannot nest them.
 
Mike Payton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I should take out the inside form and can call the same action ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any form can have any action. The contents of the form will be submitted to the form's action. It doesn't matter if multiple forms have the same action; they are independent submissions.
 
Mike Payton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.Bear Bibeault
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic