Multiple Submit in one Form using struts 1.3
It happens that in my app I throw a lot of data to one logic:iterate, but they need more data, data that is dependent on each row of the iterate. So I thought to put one submit button in each row of the iterate (or maybe a link), so I can redirect the app to the next page. Problem is, the actionForm always submit the first row of data.
I have solved this problem by using javascript: setting in the first row the data of the selected row. But I was wondering if there is any other solution, such as using indexed=”true” in the submit button and then, somehow, getting the adequate data without javascripting it.
Thanks for all!
Edit to add some example code:
<logic:iterate id="MyIterator" nam开发者_如何学编程e="sql" indexId="index">
<html:form action="MoreData" styleId="MoreData">
<tr>
<td><html:image src="docs/images/more_data.png" property="moreData" indexed="true"/></td>
<td><bean:write name="MyIterator" property="cod_user"/></td>
<td><bean:write name="MyIterator" property="txt_user"/></td>
<td><bean:write name="MyIterator" property="date_born"/></td>
<td><bean:write name="MyIterator" property="id_number"/></td>
</tr>
</html:form>
</logic:iterate>
<input type="submit" name="btn[]" value="loopVarible"/> <input type="submit" name="btn[]" value="loopVarible" />
your question is unclear without sample code.
you are probably better off with one form per row.
Is your styleId value (MoreData) the same for all forms of the page? This ends up to be the id attribute of the html form. If they are all the same, that might cause problems when submittng the form.
精彩评论