日期:2014-05-16  浏览次数:20350 次

麻烦给具checkbox 多选取值的例子
看图片啦,就是勾选后的一项,提交的时候检测右边的text有没有填写。用jqeury的。。。。麻烦高人给个js代码,谢谢!




我当前的html表单部分是:
<table class=tableframe style=word-break:break-all width="98%" align=center id="contenttableid" >
  <tbody> 
  <tr class=listtitle>
       <td class=listcelltitle align=middle  islock="true" width="33px"></td>
   <td  class=listcelltitle align=middle height="25"  width=200><div> 物料名称</div></td>
   <td  class=listcelltitle align=middle height="25"  width=100><div> 最小发注量</div></td>
   <td  class=listcelltitle align=middle height="25"  width=100><div> 采购周期</div></td>

  </tr>
  <!-- BEGIN BXBK -->
  <tr class=listrow1   bgcolor="{bgcolor}" onClick="changecolor(this,'#FFEA96','1','#FFEA96');" >
<td class=listcellrow style='WIDTH: 10px;'><input type='checkbox' id=arrlabel name='checknote[{i}]' value='{vmat_name}' ></td>
<td class=listcellrow noWrap align=left height='23' >{vmat_name}</td> 
<td class=listcellrow noWrap align=left height='23' ><input type="text" name="mat_zxfzl[]" id="mat_zxfzl[{i}]" size="12"></td> 
<td class=listcellrow noWrap align=left height='23' ><input type="text" name="mat_cgzq[]" id="mat_cgzq[{i}]" size="12">(天)</td> 
</tr>
<!-- END BXBK -->
</tbody>
</table>

------解决方案--------------------
先获取checkbox的父元素 然后获取nextSibling直到要的元素试试
------解决方案--------------------
$.each($("input[type='checkbox']"), function (i, o) {
                    if ($(this).attr("checked") == true) {
                        var txt1 = $(this).parent("td").siblings("td").find("mat_zxfzl[{i}]").val();
                        alert(txt1);
var txt2 = $(this).parent("td").siblings("td").find("mat_cgzq[{i}]").val();
alert(txt2);
                    }
                });
------解决方案--------------------
先得到checkbox checked的tr元素

$(function(){
    $trs = $("input:checked").parentsUntil("tr").parent();
    $.each($trs, function(index1, tr){
        $.each($(this).find("td:gt(1)"), function(index2, td){
         &nbs