为何我的javascripts没有反应

jiangjinsong 2007-11-28 07:50:10
我想实现的是点一下全选择,但是没有反应,我的老师只有浏览器和百度啊,请各位仁兄助我一点点进步!!!!
<script language="javascript">
var flag=true
function checkForm()
{
if(document.editArticleType.typeName.value=="")
{
alert("请填写类别名称!");
document.editArticleType.typeName.focus()
return false
}
return true

}
function selectAll()
{
for (var i=0;i<document.editArticleType.typeDel.length;i++)
{
var temp=document.editArticleType.typeDel[i];
temp.checked=!temp.checked;
}
if(flag)
{flag=false}
else
{flag=true}

}
function cancelAll()
{
for (var i=0;i<document.editArticleType.typeDel.length;i++)
{
var temp=document.editArticleType.typeDel[i];
temp.checked=!temp.checked;
}
if(flag)
{flag=false}
else
{flag=true}

}

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>

</head>
<body>
<%
on error resume next
set connLink=server.CreateObject("adodb.connection")
dbpath1=server.MapPath("/ccdata.mdb")
connLink.open "provider=microsoft.jet.oledb.4.0; data source="&dbpath1
if connLink.state <> 1 then
response.write "数据库连接错误,请检查连接字符串!错误描述为:"&err.Description
set connLink=nothing
response.end
end if

%>

<form action="addArticleType.asp" method="post" enctype="application/x-www-form-urlencoded" name="editArticleType" target="_self">
<%
set getRs=Server.CreateObject("Adodb.recordset")
getRs.open"select * from articleType order by listid",connLink,1,1
if getRs.eof then
response.Write("当前还没有文章分类")
else
response.Write "<table width='100%'align='center' border='0'>"&Vbcrlf&_
"<tr><td width='5%'></td><td width='10%'>序号</td>"&Vbcrlf&_
"<td width='40%'>标题</td>"&Vbcrlf&_
"<td width='10%'>删除</td>"&Vbcrlf&_
"<td width='10%'>编辑</td>"&Vbcrlf&_
"<td width='10%'>上移</td>"&Vbcrlf&_
"<td width='10%'>下移</td><td width='5%'></td></tr>"&Vbcrlf
Do While not(getRs.eof)
response.Write "<tr><td width='5%'></td><td width='10%'>"&getRs("id")&"</td>"&Vbcrlf&_
"<td width='40%'>"&getRs("title")&"</td>"&Vbcrlf&_
"<td width='10%'><input id='typeDel' name='typeDel' type='checkbox'value='"&getrs("id")&"'></td>"& Vbcrlf&_
"<td width='10%'>"&"<a href='editType.asp?id="&getRs("id")&"'>编辑</a>"&Vbcrlf&_
"<td width='10%'><a href='editType.asp?"&"id="&getRs("id")&"&action=up' target='_self'>"&"上移</a></d>"&Vbcrlf&_
"<td width='10%'><a href='editType.asp?"&"id="&getRs("id")&"&action=down' target='_self'>"&"下移</a></td>"
getRs.movenext
Loop
end if
set getRs=nothing

%><td width="5%"></td></tr>
</table>
<table width="100%">
<tr><td width="5%"></td>
<td width="10%"><input name="delAll" type="image" value="sellectAll" onclick="selectAll();" src="image/selectAll.gif" alt="选择全部" align="left" /></td>
<td width="10%"><input name="cancelSelect" onclick="cancelAll();" type="image" src="image/cancelSelect.gif" alt="取消所选" align="left" /></td>
<td width="10%"><input name="delSelect" type="image" src="image/delSelect.gif" alt="删除所选" align="left" /></td>
<td width="20%">类别名称:<input name="typeName" type="text" size="10" /></td>
<td width="20%"> <select name="menu" id="menu" >
<option value="请选择类别">--请选择类别--</option>
<%
set rs=Server.CreateObject("Adodb.recordset")
on error resume next
rs.open"select * from articleType order by listid",connLink,1,1
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=rs("title")%></option>
<%
rs.movenext
loop
set rs=nothing

%>

</select></td>
<td align="left" width="10%"><input id="saveData" name="saveData" type="image" src="image/saveButton.gif" alt="保存所选" align="left" onClick="return checkForm();" /></td><td width="5%"></td>
</tr>


<%

response.Write"</form></table>"
set connLink=nothing
%>


</body>
</html>
...全文
67 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiangjinsong 2007-11-29
  • 打赏
  • 举报
回复
现感谢楼上各位指点,在上班,要做其他事情,我调试完就结贴,谢谢
hztgcl1986 2007-11-29
  • 打赏
  • 举报
回复
function choice(who)
{
var inputs=document.getElementsByName("checkboxs");

for (var i=0;i<inputs.length;i++)
{
if (who == 1) //全选
{
inputs[i].checked = true;
}
else if(who == 0) //反选
{
inputs[i].checked = !(inputs[i].checked);
}

}
}

choice(1) //全选,0为反选






No_Data_Found 2007-11-29
  • 打赏
  • 举报
回复
function selectAll()
{
for (var i=0;i<document.editArticleType.typeDel.length;i++)
{
var temp=document.editArticleType.typeDel[i];
temp.checked=!temp.checked;
}
if(flag)
{flag=false}
else
{flag=true}

}

全选 应该是 temp.checked = true;

否则 temp.checked = false;
bingdian37 2007-11-29
  • 打赏
  • 举报
回复
不要发asp了,直接把html代码发出来

要调试的话,用firefox+firebug,你会非常爽的

28,391

社区成员

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

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