• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass row value to a function

 
Eye Gee Kua
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need an onclick handler; just use JSP EL to add the parameter values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic