Please help me to select all and not delete all! (Urgent !)

Source: Internet
Author: User

<SCRIPT type = "text/JavaScript">
// Set the selected status of all checkboxes Based on the selected status of the input 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 = "no." insertvisible = "false"
Readonly = "true" sortexpression = "productid"/>
<Asp: boundfield datafield = "client" headertext = "customer" sortexpression = "client"/>
<Asp: boundfield datafield = "item" headertext = "project" sortexpression = "item"/>
<Asp: boundfield datafield = "addmine" headertext = "time" sortexpression = "addmine"/>
<Asp: commandfield headertext = "operation" showdeletebutton = "true"/>
<Asp: templatefield headertext = "operation">
<Itemtemplate>
<A href = 'P _ app. aspx? Id = <% # eval ("productid") %> '0> edit </a>
</Itemtemplate>
</ASP: templatefield>
</Columns>
</ASP: gridview>
<Asp: checkbox id = "chk_js" runat = "server" text = "select all" onclick = "selectall (this)"/>
<Asp: button id = "btn_deleterecords" runat = "server" onclientclick = "Return judgeselect ();" text = "delete" onclick = "btn_deleterecords_click"/>

I also use JS
// JScript File

// Determine whether to select a record and confirm deletion
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 ("select the record to be deleted first! ");
Return result;
}
Result = confirm ("are you sure you want to delete the selected record? ");
Return result;
}

But it cannot be deleted,

Is it necessary to write back-end?Code?
 
Am I writing this?

Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.