aBgColor = ["#FFFFFF","#f2faff","#FFFFCC","#FFFFCC"];
function addTableListener(o,iHead,iEnd)
{
o.style.cursor = "normal";//这行报错,“o is null”
iHead = iHead > o.rows.length?0:iHead;
iEnd = iEnd > o.rows.length?0:iEnd;
for (var i=iHead;i<o.rows.length-iEnd ;i++ )
{
o.rows[i].onmouseover = function(){setTrBgColor(this,true)}
o.rows[i].onmouseout = function(){setTrBgColor(this,false)}
}
}
function setTrBgColor(oTr,b)
{
oTr.rowIndex % 2 != 0 ? oTr.style.backgroundColor = b ? aBgColor[3] : aBgColor[1] : oTr.style.backgroundColor = b ? aBgColor[2] : aBgColor[0];
}
window.onload = function(){addTableListener(document.getElementById("tbColor"),0,0);}
求解决
function formcheck()
{
if (form1.hot.value=="" || isNaN(form1.hot.value) )
{
alert('请输入数字');
form1.hot.focus();
return false;
}
var re = /[^\u4E00-\u9FA5]/g;
if(re.test(form1.sre.value) || form1.sre.value=="" )
{
alert('请输入中文');
form1.sre.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<center>
<form name="form1" action="login.php" method="POST" onsubmit="return formcheck();">
<fieldset style="width:400px; ">
<legend style="color:#8492B5;">添加</legend>
<table align="right" >
<tr>
<td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10" name/>id:</td>
<td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="" onsubmit="reutrn formcheck()">*输入数字</td>
</tr>
<tr>
<td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始:</td>
<td align="left" class="zhushi">
<input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
</tr>
<tr>
<td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束:</td>
<td align="left" class="zhushi">
<input type="text" id="text_name3" name="end" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
</tr>
<tr>
<td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备 注:</td>
<td align="left" class="zhushi">
<input type="text" id="text_name4" name="sre" value="">*输入中文</td>
</tr>
<tr>
<td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
<td align="left" class="zhushi"><input type="text" name="s_tp" value=""> 输入数字</td>
</tr>
<tr>
<td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容介绍:</td>
<td width="388"> </td>
</tr>
<tr>
<td align="left" colspan="2" class="zhushi">
<textarea name="ctn" id="text_name5" style="width:300px; height:50px;"></textarea>*输入中文
</td>
</tr>
<tr>
<td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
</tr>
</table>
</fieldset>
<input type="hidden" name="submit" value="submit">
</form>
aBgColor = ["#FFFFFF","#f2faff","#FFFFCC","#FFFFCC"];
function addTableListener(o,iHead,iEnd)
{
o = o || document.getElementById("tbColor");
o.style.cursor = "normal";//这行报错,“o is null”
iHead = iHead > o.rows.length?0:iHead;
iEnd = iEnd > o.rows.length?0:iEnd;
for (var i=iHead;i<o.rows.length-iEnd ;i++ )
{
o.rows[i].onmouseover = function(){setTrBgColor(this,true)}
o.rows[i].onmouseout = function(){setTrBgColor(this,false)}
}
}
function setTrBgColor(oTr,b)
{
oTr.rowIndex % 2 != 0 ? oTr.style.backgroundColor = b ? aBgColor[3] : aBgColor[1] : oTr.style.backgroundColor = b ? aBgColor[2] : aBgColor[0];
}
window.onload = function(){addTableListener(document.getElementById("tbColor"),0,0);}