2012-04-04 145 views
1

我有这种类型的表,它有很多行,每行有两列,第一列有文本,第二列有每行的复选框列表。我能够检索第一列的值,而不是每个柱子的选定复选框的值。从复选框中获取值HTML列表中的列表

我已经在Java脚本的“for”循环中使用了var cellval=Table.rows[i].cells[0].firstChild.data以获取第一列值,但是如何获取此for循环中每行的选定复选框值? (我需要映射在第二小区都有哪些选择复选框值每个第一小区值)

<tbody> 
      <% List data = (List) request.getAttribute("fiboterm");%> 
<%int i=0;%> 
     <c:forEach var="row" items="${PhraseScoreList}"> 
      <tr> 
       <td width="75%">${row.phraseContent}</td> 
       <td width="25%"> 
        <div style="overflow: auto; width: 200px; height: 75px; border: 1px solid #336699; padding-left: 5px"> 
         <%Iterator itr;%> 
         <% 
         for(int j=0;j<data.size(); j++){ 
         %> 
         <input type="checkbox" name="nums<%=i%>" id="chk[<%=i%>]" value="<%=data.get(j)%>"> <%=data.get(j)%><br> 
         <%} 
         i++; 
%> 
        </div> 
       </td> 
      </tr> 
     </c:forEach> 
     </tbody> 

回答

1

你混合代码和HTML。

1)考虑使用serlvlet和jsp和一个道。即简单的MVC架构。 使用这种说法

String[] checkboxval = request.getParameterValues("nums" + i); 

2环路和Servlet获取复选框的值),否则我建议你尝试了这一点,通过使用jQuery库;

$(document).ready(function() { 
       $("input[name=first column value").change(function() { 
        $(this).closest("tr").find("input[name^=name of value to be input]").attr("disabled", !this.checked); 
       }); 
      }); 
+0

谢谢@mykey,答案的第一个选项我能够完成任务 – Kasun 2012-07-22 16:28:09

相关问题