看看DHTML手册之控件数组
for(var i=0;i<cid.length;i++)
if(cid[i].checked)
if(sl[i].value==""){
alert("Can't Empty!");
sl[i].select(); return;
}
for(var i=0;i<cid.length;i++)
if(cid[i].checked)
if(sl[i].value==""){
alert("Can't Empty!");
sl[i].select(); return;
}
wend</form><script language="javascript">function check(){
if (document.all.cid.checked == true)
if (document.all.s1.value == "") {
alert ("the value is null;
document.all.s1.focus();
return false;
}
else
return true;
}
if (document.all.cid.checked == true)
if (document.all.s1.value == "") {
alert ("the value is null;
document.all.s1.focus();
return false;
}
else
return true;
}
</script>
function check()
{
var i=0;
while(i<=form1.elements .length-2)
{
if(form1.elements[i+1].checked==true && form1.elements[i].value=="")
{
alert("您既然已经选中了此项目,那么就必须在此项目中输入!");
form1.elements [i].focus();
return false;
}
i=i+2;
}
return true;
}
</script>
<form name="form3" method="post" action="" onsubmit="return check()>
while not rs.eof文本框:<input name="sl" type="text" class="kuang" id="sl" size="6">复选框:<input name="cid" type="checkbox" value="<% =rscp("id")%>">rs.movenext
wend
</form>