关于表单里的CheckBox控件的一些问题!郁闷很长时间了!谢谢帮忙

猞猁狲 2005-03-04 04:43:52
大家都知道163.com的邮箱吧,在收件箱的邮件列表那一页,每个邮件前面都有一个CheckBox,而且标题栏最前面也有一个CheckBox,一点这个CheckBox其它的CheckBox都被选中了!请问这个客户端脚本怎么写!谢谢!

另外还有一个愚蠢的问题!如果一个表单中有很多同名的CheckBox,提交后接收页是怎么接收这些CheckBox传过来的值的?其实说白了,我不明白CheckBox的工作原理,怎么判断是哪条邮件的CheckBox传过来的值!

谢谢大家,一定帮帮忙呀!
...全文
141 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bingbingcha 2005-03-05
  • 打赏
  • 举报
回复
楼上的方法不适用再表单内有多个复选框,或者单选框的时候...

楼主用下面的代码看看:
直接拷贝到HTML文件测试就可以看到结果..选取的只是你指定的内容

======================================================

<html>
<head>
<title>标题</title>
<script language="JavaScript">
ii = 0
function aa(){
var i;
for(i=0;i<document.form1.elements.length;i++){

if (ii%2==1){
if (document.form1.elements[i].name=="aaaa") document.form1.elements[i].checked = true;
}else{
if (document.form1.elements[i].name=="aaaa") document.form1.elements[i].checked = false;
}
}

}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="checkbox" name="checkbox" onClick="ii++;aa()" value="checkbox">
选取</p>
<p>
<input name="aaaa" type="checkbox" id="aaaa" value="111">
<input name="aaaa" type="checkbox" id="aaaa" value="2222">
<input name="aaaa" type="checkbox" id="aaaa" value="3333">
<input name="aaaa" type="checkbox" id="aaaa" value="4444">
<input name="aaaa" type="checkbox" id="aaaa" value="55555">
<input name="aaaa" type="checkbox" id="aaaa" value="66666">
<input name="aaaa" type="checkbox" id="aaaa" value="77777">
</p>
<input type="radio" name="radiobutton" value="radiobutton">
<input type="radio" name="radiobutton" value="radiobutton">
<input type="radio" name="radiobutton" value="radiobutton">
</form>
</body>
</html>
ronakitty 2005-03-05
  • 打赏
  • 举报
回复
list.asp
-------------------------------------
<script language="JavaScript">
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
</script>


<form name="form1" method="post" action="del.asp">
<table>
<tr>
<td>题目</td>
<td>删除</td>
</tr>
<tr>
<td><%=rs("name")%></td>
<td><input name="id" type="checkbox" id="id" value="<%=rs("id")%>"></td>
</tr>
<tr>
<td colspan="2">
将所选择的文件进行
<input type="submit" name="Submit" value="删除">
操作    全选
<input type=checkbox value="on" name="chkall" onClick="CheckAll(this.form)">
</td>
</tr>
</table>
</form>


del.asp
-------------------------------------
id = chkstr(trim(request("id")))
if id <> "" then
fileid = split(id,", ")
for i=0 to ubound(fileid)
if fileid(i) <> "" then
sql="delete from 表名 where id="& fileid(i)
conn.execute(sql)
end if
next
end if
泉畔人家 2005-03-05
  • 打赏
  • 举报
回复
http://dev.csdn.net/article/article/50/50798.shtm
猞猁狲 2005-03-05
  • 打赏
  • 举报
回复
怎么没有人回答呀?我的问题太简单了!还是没人知道?〉

28,391

社区成员

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

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