看图片啦,就是勾选后的一项,提交的时候检测右边的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>
我当前的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>
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);
}
});
$trs = $("input:checked").parentsUntil("tr").parent();
$.each($trs, function(index1, tr){
$.each($(this).find("td:gt(1)"), function(index2, td){
//这里就可以对每个td里面的内容进行判断了,我这里选择的td是从第三列开始的,如果要变的话你就改find()这边的选择器好了
});
});
});
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE> New Document </TITLE>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function validate() {
var $trs = $('#contenttableid tr'); $trs.each(function(){
var $tr = $(this);
if($tr.find("input[type='checkbox']").attr('checked')) {
var $texts = $tr.find("input[type='text']");
$texts.each(function(){
if(!this.value) {
alert('未填写值')
}
});
}
});
}
</script>
</HEAD><BODY>
<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}" >
<td class=listcellrow style='WIDTH: 10px;'><input type='checkbox' id=arrlabel name='checknote[{i}]' value='ddddd' ></td>
<td class=listcellrow noWrap align=left height='23' >物料名称aaa</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>
<INPUT TYPE="button" VALUE="验证" ONCLICK="validate()">
</BODY>
</HTML>