• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problems with form

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to get the values of a form in an action but the problem I have is that they get no value at all.

I have a button that submits the form but it is out of it...what can I do to get these values?
the button has to be outside of the form...


this is my code:




<html:form action="/sam/updateEntity">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<nested:iterate property="availableAttributes">
<tr>
<td valign="top" align="left" width="15%">
<img src="../images/spacer.gif" width="20"/><font class="label"><nested:write property="attribute.name"/>:</font>
</td>
<td width="85%">
<nested:nest property="attribute.attributeType">
<nested:equal property="name" value="single line text area">
<nested:text property="../../value" size="35"/>
</nested:equal>
<nested:equal property="name" value="check box">
<nested:checkbox property="../../value"/>
</nested:equal>
<nested:equal property="name" value="drop down menu">
<nested:select property="../../value">
<html ption value=""> </html ption>//this is an empty option, do not change it
<nested ptions property="../possibleValuesAsStringArray"/>
</nested:select>
</nested:equal>

<nested:equal property="name" value="multi line text area">
<nested:textarea property="../../value" rows="4" cols="28"/>
</nested:equal>
</nested:nest>
</td>
</tr>
</nested:iterate>
<tr>
<td height="10"> </td>
</tr>
<tr>

<td colspan="2">
<hr>

</td>
</tr>
</table>
</html:form>


more code in between....



<html:form action="/sam/updateEntity">
<input type="image" src="../images/button_save_bold.gif" alt="Save Entity" title="Save Entity" accesskey="V">
</html:form>
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way I know to submit one form from a button in another form is through JavaScript. For example, if the form you want to submit is the first form on the page and the form containing the button is in the second form on the page, you could do something like this:

*Note: onklick above should be onclick
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did so in my js code but the form fields don't get any value

any other idea?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will work if done properly. Show us your code.

One question: Are you absolutely sure that the form you want to submit is the first one on the page? If you're using tiles, another tile may be adding a form to the page.
[ February 22, 2007: Message edited by: Merrill Higginson ]
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I tried what you suggest...

the problem now is that when I hit the save button the action is accessed twice.The first time it get the values of the form correctly but the second time it lose them.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you writing this onclick event in a submit button? If so, that's the problem. This would cause the submit to occur twice: once from the onclick event and once from the submit button itself.

Solution: use either <html:button> or <input type="button" > instead of <html:submit> or <input type="submit" />
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used an <a> tag insted of an input image and It works now...
reply
    Bookmark Topic Watch Topic
  • New Topic