Complete check box checkbox with JS select \ reverse Select \ Delete Confirmation

Source: Internet
Author: User

The code is as follows:

<script language= "JavaScript" >

<!--

Check function detects whether an article is selected

function Check (OJ)

{

var D=false; Define a marker

for (Var i=0;i<oj.length;i++)

{

if (oj[i].checked)

{

D=true;

}

}

Use loops to determine if an article is selected

if (d)

{

var f=confirm ("Are you sure you want to delete the selected?") ");/sure whether to delete;

if (f)

{

return true; Be sure to delete;

}

Else

{

return false; Do not delete;

}

}

Else

{

Alert (Please select the article you want to delete.) ");//unchecked, prompt

return false;

}

}

Checkall for Set Select All

function Checkall (OJ)

{

for (Var i=0;i<oj.length;i++)

{

Oj[i].checked=true;

}

}

Checkback to set up a reverse selection

function Checkback (OJ)

{

for (Var i=0;i<oj.length;i++)

{

if (oj[i].checked)

{

Oj[i].checked=false;

}

Else

{

Oj[i].checked=true;

}

}

}

-->

</SCRIPT>

<CENTER><H2> Article Management </H2></CENTER>

<table align= "center" width= "border=" 1 ">

<form method= "POST" action= "name=" MyForm "onsubmit=" return check (Document.myform.del); " >

<TR>

<td><input type= "checkbox" Name= "del" value= "1" ></TD>

<TD> about the employment problem of college students. </TD>

<TD> Edit </TD>

</TR>

<TR>

<td><input type= "checkbox" Name= "del" value= "2" ></TD>

<TD>07 students do not charge tuition fees in normal years. </TD>

<TD> Edit </TD>

</TR>

<TR>

<td><input type= "checkbox" Name= "del" value= "3" ></TD>

<TD> human civilization is suffering from aggression </TD>

<TD> Edit </TD>

</TR>

<TR>

<td><input type= "checkbox" Name= "del" value= "4" ></TD>

Love </TD> in the novels of <TD> Cologne

<TD> Edit </TD>

</TR>

<TR>

<TD>&nbsp;</TD>

<TD align= "center" ><input type= "button" value= "Select All" onclick= "Checkall (Document.myform.del)" >&nbsp; &nbsp;<input type= "button" value= "onclick=" Checkback (Document.myform.del) >&nbsp;&nbsp;< INPUT type= "Submit" value= "delete" >&nbsp;&nbsp;<input type= "reset" value= "re-election" ></TD>

<TD>&nbsp;</TD>

</TR>

</FORM>

</TABLE>

Operation Effect:

Select two items:

Click on the reverse selection:

Click to select All:

Delete Confirmation:

No prompts selected:

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.