javascript - Form under Loop construct not working as expected -
improper form submission
for below code snippet, not able value input hidden field in request.
in form table created:
it working fine, if click approve button of first row.
issue faced when approve button of intermediate row clicked. there no value passed in request id="hidinput";
<script> function fetchid(){ var contentid = document.getelementbyid("testid").innerhtml; document.getelementbyid("hidinput").value=contentid; } </script> <%for (appl_testimonial_txn testimonial_txn : results) {%> <tr> <form action="<%=approve.tostring()%>" method="post"> <td id="testid"><%=testimonial_txn != null ? testimonial_txn .gettestimonialid() : ""%></td> <input type="hidden" name="rowid" id="hidinput" value=""/> <td><button class="button-continue continuenew" type="submit" onclick="fetchid()">approve</button></td> </form> </tr> <%}%>
as per code above, there no way figure out row in approve button clicked. can pass testimonial id fetchid function.
<script> function fetchid(contentid){ document.getelementbyid("hidinput").value=contentid; } <script> <tr> <form action="<%=approve.tostring()%>" method="post"> <td><%=testimonial_txn != null ? testimonial_txn .gettestimonialid() : ""%></td> <input type="hidden" name="rowid" id="hidinput" value=""/> <td><button class="button-continue continuenew" type="submit" onclick="fetchid('<%=testimonial_txn != null ? testimonial_txn .gettestimonialid() : ""%>')">approve</button></td> </form> </tr> <%}%> 
Comments
Post a Comment