File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to pass row value to a function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to pass row value to a function" Watch "How to pass row value to a function" New topic
Author

How to pass row value to a function

Eye Gee Kua
Greenhorn

Joined: Oct 01, 2010
Posts: 1
Hi,

I have a table of rows with checkboxes. When I click on 1 checkbox i need to pass the row value to a function. Any sample how I can achieve this?
I would like to pass the customerAccNo and customerId to a function. I am new to jsp and javascript, can someone please guide me?


Below is the sample codes:

<%
int row = 1;
List<CustomerVO> list = (List<CustomerVO>) request.getAttribute("MSG_CUSTOMER_LIST");
if (list.size() == 0) {
%>
<tr>
<td colspan="4" align="center">No result.</td>
</tr>
<% }
if (list.size() == 1 && pageNum == 1) {
String customerNameEsc = HTMLUtil.escapeQuote(list.get(0).getCustomerName());
%>
<script>window.opener.eporderSearchCustOnSelect('<%= customerNameEsc%>'); window.close();</script>
<%
}

for (CustomerVO vo : list) {
String customerAccNo = HTMLUtil.nbsp(vo.getCustomerAccNo());
String customerId = HTMLUtil.nbsp(vo.getCustomerId());
String customerName = HTMLUtil.nbsp(vo.getCustomerName());
String customerNameEsc = HTMLUtil.escapeHTMLQuote(vo.getCustomerName());
%>

<tr>
<td align="center">
<html:checkbox property="customer" />
<input type="hidden" id="customerName<%= row%>" value="<%= customerNameEsc%>" />
<input type="hidden" id="customerId<%= row%>" value="<%= customerId%>" />
</td>
<td><%= customerAccNo%></td>
<td><%= customerId%></td>
<td><%= customerName%></td>
</tr>
<%
row++;
}
%>


Regards,
Eye Gee
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags for code and configuration; unformatted code is difficult to read, and people are more likely to answer if things are as clear as possible. Thanks!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You need an onclick handler; just use JSP EL to add the parameter values.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to pass row value to a function
 
Similar Threads
save checked value in checkbox to database
calling the struts action on jquery button click
How to to validation in java script involve two jsp page?
spaces while populating using s:iterator
Question related to logic:iterate tag