日期:2014-05-17  浏览次数:21440 次

如何检测选中的checkbox的个数
我用do   while   not   rs.eof循环生成了新闻之前的checkbox。如何检测被选中的checkbox个数?当没有新闻被选中时,又怎么用msgbox提示不能进行下一步操作?(我用VBSCRIPT)

------解决方案--------------------
<script language= "vbscript ">
Function checkme()
checkme =true
Dim inCount
Dim strValue
inCount = 0
For Each ob In form1.chk
if ob.checked then
inCount = inCount + 1
If strValue = " " Then
strValue = ob.value
Else
strValue = strValue & ", " & ob.value
End If
End If
Next
If inCount = 0 Then
MsgBox "No Checked "
checkme =false
Exit Function
Else
MsgBox inCount & " Checked, Value= " & strValue
Submit()
End if
end Function
</script>
<BODY>
<form name= "form1 " action= "dd.asp " method= "post ">
<INPUT name= "chk " type= "checkbox " value= "北京 " checked> 北京
<INPUT name= "chk " type= "checkbox " value= "上海 "> 上海
<INPUT name= "chk " type= "checkbox " value= "广州 "> 广州
<INPUT name= "chk " type= "checkbox " value= "深圳 "> 深圳
<INPUT type= "submit " value= "check " onclick= "checkme ">
</form>