复选框里的数据如何获取啊!????请高手指教,谢谢!

greenberet007 2005-07-26 05:04:14
复选框里的数据如何获取啊!????请高手指教,谢谢!
...全文
108 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
安迪 2005-07-26
  • 打赏
  • 举报
回复
把你代码里下边的这部分中的n用"<%=count%>"来替换,而这个count,要再去数据的循环中的服务器端的代码中进行类加(count=count+1);"document.form1.num[1].value"中的"1"用i来替换
function checkorder()
{
for (i=0;i<n;i++)

{
if(document.form1.num[1].value!="")
{
if(isNaN(document.form1.num[1].value))
{alert("您输入的商品数量格式不正确!"); return false;}
alert("您已经成功订购了这些商品");
}
else
alert("输入的商品数量不能为空");
return false;
}
}




greenberet007 2005-07-26
  • 打赏
  • 举报
回复
谢谢你的指点
那么这个问题该如何解决呢??
一次只能判断一个,不能一起判断啊!!
我的文本框的name都是num
function checkorder()
{
for (i=0;i<n;i++)

{
if(document.form1.num.value!="")
{
if(isNaN(document.form1.num.value))
{alert("您输入的商品数量格式不正确!"); return false;}
alert("您已经成功订购了这些商品");
}
else
alert("输入的商品数量不能为空");
return false;
}
}
haver.G 2005-07-26
  • 打赏
  • 举报
回复
可以直接用Request.form("num")取得被选中的值,格式是每个值有“,”逗号隔开
然后可以用Split去处理
greenberet007 2005-07-26
  • 打赏
  • 举报
回复
我要一次判断多个文本框里的数据规则该怎么写代码啊??
谢谢高手.

function checkorder()
{
for (i=0;i<n;i++)

{
if(document.form1.num[1].value!="")
{
if(isNaN(document.form1.num[1].value))
{alert("您输入的商品数量格式不正确!"); return false;}
alert("您已经成功订购了这些商品");
}
else
alert("输入的商品数量不能为空");
return false;
}
}




<BODY>
<%
str="Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=Merchandise;Data Source=."
set cn=server.createobject("adodb.connection")
cn.open str

sql="select distinct * from Merchandise"
set rs=server.createobject("adodb.recordset")
rs.open sql,cn,1,3
%>
<table border=1 bordercolor=#F45892>
<form name="form1" method="post" target="buy_2.asp" onsubmit="return checkorder()">
<tr>
<td colspan=3 align="center">购物界面</td>
</tr>
<%
while not rs.eof
response.write "<tr><td><input type='checkbox' name='m1' value=" & rs(1) & ">" & rs(1) & "</td>"
response.write "<td>价格:" & rs(7) & "</td>"
response.write "<td>你要订购的数量:<input type=text name=num id=num value=0 maxlength=5></td></tr>" '例如此处有10条记录,即10条文本框,我要判断这10条的命名规则
rs.movenext()
wend



cn.close()
set cn=nothing
set rs=nothing
%>

<tr><td align="center" colspan=3>
<table align="center">
<tr>
<td><input type="submit" name="submit" value="提交">
            </td>
<td><input type="reset" name="reset" value="重置"></td>
</tr>
</table>
</td></tr>

</form>
</table>
</BODY>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧