I have written following code to pass a variable artpsMstId
to a javascript function and then update the record stored against that variable:
In JSP:
<td>
<a href="javascript:fnUpdate('<s:property value="artpsMstId" />');">testupdate</a>
</td>
<script type="text/javascript">
function fnUpdate(id)
{
<s:url action='updateServiceDetails'></s:url>
document.forms[0].artpsMstId.value=id;
document.forms[0].submit();
}
</script>
In struts.xml:
<action name="updateServiceDetails" class="com.stp.portal.view.SearchServicePortlet" method="updateServiceDetails">
<result name="success">/WEB-INF/view/ServiceSubmitPage.jsp</result>
</action>
The I have defined the function updateServiceDetails
in the SearchServicePortlet.java
. But the flow is not coming to the SearchServicePortlet.java
. would really appreciate if anyone could help me...Thanks
----EDITED-----
Here is what basically I want to do
<s:form action="updateServiceDetails" method="POST" theme="simple" >
<tr>
<td>
FirstName
</td>
<td>
LastName
</td>
<td>
Edit
</td>
</tr>
<s:iterator value="resultList" >
<tr>
<td align="center">
<s:textfield name="firstName" />
</td>
<td align="center">
<s:textfield name="lastName" />
</td>
<td>
Edit
</td>
<td align="center">
<a href="javascript:fnUpdate('<s:property value="artpsMstId" />');">testupdate</a>
</td>
</tr>
</s:iterator>
</s:form>
Above code displays a list with first names and last names with an edit option for each row. Now I want to call the function fnUpdate()
in a javascript so that I can edit and save each row separately. This is what I basically need to do.
Instead of having form over entire table, just have seperate form and on click on link in row of table, call javascript function to submit that seperate form,
Try below code, in jsp,
<form name="updateServiceDetailForm">
<input type="hidden" name="artpsMstId"/>
</form>
<table>
<tr>
<td>
FirstName
</td>
<td>
LastName
</td>
<td>
Edit
</td>
</tr>
<s:iterator value="resultList" >
<tr>
<td align="center">
<s:textfield name="firstName" />
</td>
<td align="center">
<s:textfield name="lastName" />
</td>
<td>
Edit
</td>
<td align="center">
<a href="javascript:fnUpdate('%{artpsMstId}');">testupdate</a>
</td>
</tr>
</table>
in javascript,
function fnUpdate(artpsMstId) {
document.forms.updateServiceDetailForm.action = "updateServiceDetails.action";
document.forms.updateServiceDetailForm.method = "post";
document.forms.updateServiceDetailForm.artpsMstId.value = artpsMstId;
document.forms.updateServiceDetailForm.submit();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.