61,114
社区成员
发帖
与我相关
我的任务
分享
<style>
.tip{
height:20px;
color:red;
display:block;
width:150px;
font-size:12px;
font-weight: normal;
text-align:center;
}
</style>
<form method="post" action="xxx.php" enctype="multipart/form-data" name="form" onSubmit="javascript:return Submit(this)">
name:<input name="name" type="text" id="name" size="10" class="box">
<table id="tb1" >
<tr>
<td bgcolor="#FFFFFF" class="f_c">事项<input type="hidden" name="id_1" id="id_1" value="2" /></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_1[]" id="id_1" value="A"> A、项目1 <b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="B"> B、项目2<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="C"> C、项目3<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="f_c">成效<Input type="hidden" name="id_2" id="id_2" value="2"></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_2[]" id="id_2" value="A"> A、成效1<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_2[]" id="xtgn_2" value="B"> B、成效2<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<input type=submit value="提交" />
</form>
<script>
var tb=document.getElementById('tb1');
var chs=[],_chs=tb.getElementsByTagName('input');
var texts=tb.getElementsByTagName('textarea');
var tips=tb.getElementsByTagName('b'),idx=0;
function trim(s){ return s.replace(/^\s*|\s*$/g,'') };
for(var i=0;i<_chs.length;i++) if(_chs[i].type=='checkbox') {
_chs[i].i=idx++;
_chs[i].onclick=function(){ tips[this.i].innerHTML=this.checked?'所有项目为必填':'' }
chs.push(_chs[i])
}
function check(){
var r=chs.length,c=texts.length/r;
while(r--){
for(var i=0;chs[r].checked&&i<c;i++)
if(!trim(texts[ r*c+i].value) ) return false;
}
return true;
}
function Submit(f){
if(!check() ){
alert('选中事项xxxx不能为空');
return false;
}else if( f.name.value=="" ){
alert('name不能为空');
return false;
}
return true;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head>
<body>
<table>
<tr>
<td bgcolor="#FFFFFF" class="f_c">事项<Input type="hidden" name="id_1" id="id_1" value="2"></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_1[]" id="id_1" value="A"> A、项目1</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="B"> B、项目2</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="C"> C、项目3</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="f_c">成效<Input type="hidden" name="id_2" id="id_2" value="2"></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_2[]" id="id_2" value="A"> A、成效1</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_2[]" id="xtgn_2" value="B"> B、成效2</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">
$(':checkbox').click(function(){
var status=this.checked;
if(status){
$(this).parent().parent().find('textarea').attr('placeholder','项目相关描述必填噢');
}else{
$(this).parent().parent().find('textarea').removeAttr('placeholder');
}
});
</script>
</body>
</html>
<table id="tb1" >
<tr>
<td bgcolor="#FFFFFF" class="f_c">事项<input type="hidden" name="id_1" id="id_1" value="2" /> </td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_1[]" id="id_1" value="A"> A、项目1</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="B"> B、项目2</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="C"> C、项目3</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="f_c">成效<Input type="hidden" name="id_2" id="id_2" value="2"></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_2[]" id="id_2" value="A"> A、成效1</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_2[]" id="xtgn_2" value="B"> B、成效2</td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<input type=button value="test" onclick="Submit()" />
<script>
var tb=document.getElementById('tb1');
var chs=[],_chs=tb.getElementsByTagName('input');
var texts=tb.getElementsByTagName('textarea');
function trim(s){ return s.replace(/^\s*|\s*$/g,'') };
for(var i=0;i<_chs.length;i++) if(_chs[i].type=='checkbox') chs.push(_chs[i])
function check(){
var r=chs.length,c=texts.length/r;
while(r--){
for(var i=0;chs[r].checked&&i<c;i++)
if(!trim(texts[ r*c+i].value) ) return false
}
return true;
}
function Submit(){
alert( check() );
}
</script>
<style>
.tip{
height:20px;
color:red;
display:block;
width:150px;
font-size:12px;
font-weight: normal;
text-align:center;
}
</style>
<table id="tb1" >
<tr>
<td bgcolor="#FFFFFF" class="f_c">事项<input type="hidden" name="id_1" id="id_1" value="2" /></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_1[]" id="id_1" value="A"> A、项目1 <b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="B"> B、项目2<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_1[]" id="xtgn_1" value="C"> C、项目3<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_1" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="f_c">成效<Input type="hidden" name="id_2" id="id_2" value="2"></td>
<td bgcolor="#FFFFFF" colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c7e9ff">
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="id_2[]" id="id_2" value="A"> A、成效1<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="35%"><input type="checkbox" name="xtgn_2[]" id="xtgn_2" value="B"> B、成效2<b class="tip" ></b></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="name_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="24%"><textarea name="bsfs_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
<td bgcolor="#FFFFFF" width="17%"><textarea name="synx_2" class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+16)+'px');overflow:auto;"></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<input type=button value="test" onclick="Submit()" />
<script>
var tb=document.getElementById('tb1');
var chs=[],_chs=tb.getElementsByTagName('input');
var texts=tb.getElementsByTagName('textarea');
var tips=tb.getElementsByTagName('b'),idx=0;
function trim(s){ return s.replace(/^\s*|\s*$/g,'') };
for(var i=0;i<_chs.length;i++) if(_chs[i].type=='checkbox') {
_chs[i].i=idx++;
_chs[i].onclick=function(){ tips[this.i].innerHTML=this.checked?'所有项目为必填':'' }
chs.push(_chs[i])
}
function check(){
var r=chs.length,c=texts.length/r;
while(r--){
for(var i=0;chs[r].checked&&i<c;i++)
if(!trim(texts[ r*c+i].value) ) return false;
}
return true;
}
function Submit(){
alert( check() );
}
</script>