Function CheckForm()
set cb=document.getElementsByName("v")
c=0
for each e in cb
if e.checked Then
c = c+1
if c > 10 Then
alert("超过10项,不允许提交!")
CheckForm = false
end if
end if
next
End Function
set cb=document.getElementsByName("v")
c=0
for each e in cb
if e.checked Then
c = c+1
if c > 10 Then
alert("超过10项,不允许提交!")
CheckForm = false
end if
end if
next
End Function
解决方案 »
- ~~下拉列表框事件~~~的问题,求助!!!
- 谁帮我简洁下代码呀
- JavaScript字符串计算
- 取3个数中的最大值[简单高效法]!
- 简单的正则表达式问题
- Eclipse 项目中引用外部javascript文件的问题
- 请问点击一个<a>标签能同时更新2个<iframe>的src吗?
- 数组排序问题???
- 在线答题系统,怎么随机出题
- 求大佬帮忙看看script里面写的img网络地址怎么刷不出来图片
- 怎样获取textarea中每行的值, 并且要去掉回车符的, 多谢了
- ie浏览器好像不支持通过属性选择符,即不支持E1[attr=value]{}方式,那我想对<input type=text>和<input type=button>有不同的样式,css
Function CheckForm()
set cb=document.getElementsByName("v")
c=0
for each e in cb
if e.checked Then
c = c+1
if c > 10 Then
alert("超过10项,不允许提交!")
CheckForm = false
end if
end if
next
End Function
%>document.write ("<form method='post' onSubmit='return CheckForm();' action='votes.asp'><table border='1' cellpadding='5' cellspacing='0' bordercolordark='#f7f7f7' bordercolorlight='#cccccc' class='inputt'>");点选超过10项的话,就弹出对话框 不让提交。 这样写有什么错吗? 页面能出来 但是没效果
document.getElementsByName是客户端的脚本用法,
希望大虾能帮忙解决这个小问题document.write ("<form method='post' action='votes.asp'><table border='1' cellpadding='5' cellspacing='0' bordercolordark='#f7f7f7' bordercolorlight='#cccccc' class='inputt'>");
这个是源文件的内容
我想加个程序判断一下,别选超过10项,如果超过了10项,就不让提交万分感谢 如果需要的话 下面的是整个源程序<!-- #include file="conn.asp"-->
document.write ("<html><head><title>投票</title>");
document.write ("<link href='css.css' rel='stylesheet' type='text/css'>");
document.write ("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>");
document.write ("</head><body>");
document.write ("<form method='post' action='votes.asp'><table border='1' cellpadding='5' cellspacing='0' bordercolordark='#f7f7f7' bordercolorlight='#cccccc' class='inputt'>");<%
on error resume next
dim id,rs,chk
ip=Request.ServerVariables("REMOTE_ADDR")
id=request.querystring("id")
if id<>"" then
set rs=server.createobject("adodb.recordset")
rs.open "select title,types,brstr from V_title where id=cint('"&id&"')",conn,1,1
if not rs.eof then
chk=rs("types")
%>
document.write ("<tr><td bgcolor='#f7f7f7' height='30'><font color='#ff0000'><%=rs("title")%></font></td></tr><tr><td><table border='0' width='100%' class='inputt'>");<%
dim rs1,i
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from V_vote where lid=cint('"&id&"')",conn,1,1
if not rs1.eof then
do while not rs1.eof
if i<>0 then
if (i mod rs("brstr"))=0 then
%>
document.write ("<tr>"); <%end if
end if
%>
document.write ("<td>");
<%
select case rs("types")
case "1" '单选
%>
document.write ("<img src='<%=rs1("img")%>'><br><input type='radio' name='v' value='<%=rs1("id")%>'><%=rs1("cont")%><br>");
<%
case "2" '多选
%>
document.write ("<img src='<%=rs1("img")%>'><br><input type='checkbox' name='v' value='<%=rs1("id")%>'><%=rs1("cont")%><br>");
<%
end select%>
document.write ("</td>");<%
i=i+1
rs1.movenext
loop
end if
rs1.close
%>
<%
end if
rs.close
end if
%>
document.write ("</table></td></tr>");
document.write ("<tr><td bgcolor='#f7f7f7' height='30' align='center'><input type='hidden' name='ip' value='<%=ip%>'><input type='hidden' name='idd' value='<%=id%>'><input type='submit' name='submit1' value='投票' class='inputt'> <input type='button' name='button1' value='查看' class='inputt' onclick=window.open('view.asp?id=<%=id%>','vie','scrollbars=yes,resizable=yes,width=550,height=250');><input type='hidden' name='id' value='<%=id%>'><input type='hidden' name='chk' value='<%=chk%>'></td></tr></table></form></body></html>");
document.write ("<form method='post' action='votes.asp' onsubmit="return CheckForm()"><table border='1' cellpadding='5' cellspacing='0' bordercolordark='#f7f7f7' bordercolorlight='#cccccc' class='inputt'>");