aspose 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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass row value to a function