var tableobj=document.getElementById("data");
var name=0,name1=0,same=true;
var selected;var id=0;
for(var i=0;i<need.length;i++){
if(need.item(i).type == 'checkbox'){
if(document.need.item(i).checked){
id=id+","+document.need.item(i).value;
name = tableobj.rows[i].cells[2].innerText;
//alert(name);
if(name!=name1&&name!=0&&name1!=0){
same=false;
break;
}
name1 = name;
selected=document.need.item(i).checked;
}
}
}
if(!selected){
alert("请选择要打印的记录!");
return false;
}
if(!same){
alert("请选择同一客户名称的记录!");
return false;
}
bordercolor="#003366"
style="border: 1px; border-collapse: collapse;" align="center"
cellpadding="0" cellspacing="1"> <tr bgcolor="#336699" height="24">
<td width="2%" align="center">
<font color="#FFFFFF"></font>
</td>
<td width="10%" align="center">
<font color="#FFFFFF">客户代码</font>
</td>
<td width="20%" align="center">
<font color="#FFFFFF">客户名称</font>
</td>
<td width="10%" align="center">
<font color="#FFFFFF">订单号</font>
</td>
<td width="24%" align="center">
<font color="#FFFFFF">产品名称</font>
</td>
<td width="8%" align="center">
<font color="#FFFFFF">分配数量</font>
</td>
<td width="8%" align="center">
<font color="#FFFFFF">分配件数</font>
</td>
<td width="18%" align="center">
<font color="#FFFFFF">技术要求</font>
</td>
</tr> <c:forEach var="pick" items="${picklist}">
<c:choose>
<c:when test="${pick.dv_status==349}">
<tr bgcolor="#38b875">
<td height="20" align="center">
</td>
<td height="20" align="center">
${pick.dv_cuscode}
</td>
<td height="20" align="center">
${pick.dv_cusname}
</td>
<td height="20" align="center">
${pick.dv_pono}
</td>
<td height="20" align="center">
${pick.dv_product}
</td>
<td height="20" align="center">
${pick.dv_num}
</td>
<td height="20" align="center">
${pick.dv_item}
</td>
<td height="20" align="center">
${pick.dv_skilled}
</td>
</tr>
</c:when>
<c:otherwise>
<tr bgcolor="#9ECAEB">
<td height="20" align="center">
<input type="checkbox" name="pickno" class="input"
value="${pick.dv_pickno}">
</td>
<td height="20" align="center">
${pick.dv_cuscode}
</td>
<td height="20" align="center">
${pick.dv_cusname}
</td>
<td height="20" align="center">
${pick.dv_pono}
</td>
<td height="20" align="center">
${pick.dv_product}
</td>
<td height="20" align="center">
${pick.dv_num}
</td>
<td height="20" align="center">
${pick.dv_item}
</td>
<td height="20" align="center">
${pick.dv_skilled}
</td>
</tr>
</c:otherwise>
</c:choose> </c:forEach> </table>
可是 当输出 jS里注释的那个NAME时 发现值总是有错误!!!!!!
发现:tableobj.rows[i].cells[2].innerText; 不正常时
改成tableobj.rows[i].cells[i-2].innerText; 正常
,反之亦然
问题是发现了 可是怎么弄都没弄正确 tableobj.rows[i].cells[2].innerText;
获得表格的值 不太会用
if(need.item(i).type == 'checkbox'){need是个啥?list?
你是不是只把有checkbox的内容放到need里了?
那么你的need和table的索引根本就对不上
need是form表单的名字
代码主要是JS部分的错误
就是两个下标对不上的原因,
比如你的table共5行,第一三五行没有checkbox
那么你的need.item(0)checkbox实际在table的第2行,
need.item(1)checkbox实际在table的第4行,
明白了么?
是的 这就是原因,可是我不会解决 我一开始也就是发现了这个问题
唯一想到的办法是全部加上CHECKBOX 但是我用全选功能,能把不可用的CHECKBOX也选上
所以 目前请各位帮我解决一下 怎么解决这个问题