请各位帮下我,实现了全选,实现不了全部删除!(急!)
<script type="text/javascript">
//根据传入的checkbox的选中状态设置所有checkbox的选中状态
function selectAll(obj)
{
var allInput = document.getElementsByTagName("input");
//alert(allInput.length);
var loopTime = allInput.length;
for(i = 0;i < loopTime;i++)
{
//alert(allInput[i].type);
if(allInput[i].type == "checkbox")
{
allInput[i].checked = obj.checked;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 497px; height: 363px">
<tr>
<td rowspan="3" style="width: 100px">
<uc1:carte ID="Carte1" runat="server" />
</td>
<td colspan="2" rowspan="3">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="ProductId" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk_Del" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ProductId" HeaderText="编号" InsertVisible="False"
ReadOnly="True" SortExpression="ProductId" />
<asp:BoundField DataField="Client" HeaderText="客户" SortExpression="Client" />
<asp:BoundField DataField="Item" HeaderText="项目" SortExpression="Item" />
<asp:BoundField DataField="Addmine" HeaderText="时间" SortExpression="Addmine" />
<asp:CommandField HeaderText="操作" ShowDeleteButton="True" />
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<a href='P_app.aspx?Id= <%# Eval("ProductId") %> ' 0> 编辑 </a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:CheckBox ID="chk_JS" runat="server" Text="全选" onclick="selectAll(this)"/>
<asp:Button ID="btn_DeleteRecords" runat="server" OnClientClick="return judgeSelect();" Text="删除" OnClick="btn_DeleteRecords_Click" />
我还用js
// JScript 文件
//判断是否选中记录,用户确认删除
function judgeSelect()
{
var result = false;
var allInput = document.getElementsByTagName("input");
var loopTime = allInput.length;
for(i = 0;i < loopTime;i++)
{
if(allInput[i].checked)
{
result = true;
break;
}
}
if(!result)
{
alert("请先选则要删除的记录!");
return result;
}
result = confirm("你确认要删除选定的记录吗?");
return result;
}
可就是删除不了,
是不是还要写后台代码?
我这样写对么?
请各位大哥大姐帮下我,在这先谢谢你们啦!