<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
1
<
SCRIPT
LANGUAGE
="JavaScript"
>
2
3 var checkflag = false ;
4 function check(field)
5 {
6
7
8 if (checkflag == false )
9 {
10
11 if (field.length == null )
12 {
13
14 field.checked = true ;
15 checkflag = true ;
16 // return false;
17
18 }
19
20 for (i = 0 ; i < field.length; i ++ )
21 {
22
23 field[i].checked = true ;
24 }
25 checkflag = true ;
26 // return "false";
27 } else
28 {
29
30 if (field.length == null )
31 {
32
33 field.checked = false ;
34 checkflag = false ;
35 // return true;
36
37 }
38 for (i = 0 ; i < field.length; i ++ )
39 {
40 field[i].checked = false ;
41 }
42 checkflag = false ;
43 // return true;
44 }
45 }
46 </ script >
47
48 < html >
49 < head >
50 < meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" >
51 < title > 无标题文档 </ title >
52 </ head >
53
54 < body >
55 < form name ="form1" method ="post" action ="" >
56 < p >
57 < input type ="checkbox" name ="ckbox" value ="checkbox" >
58 dfg </ p >
59 < p >
60 < input type ="checkbox" name ="ckbox" value ="checkbox" >
61 dfg
62 </ p >
63 < p >< br >
64 < input type ="checkbox" name ="全选" onClick ="this.value=check(this.form.ckbox)" >
65 全选 </ p >
66 < p > </ p >
67 </ form >
68 </ body >
69 </ html >
70
2
3 var checkflag = false ;
4 function check(field)
5 {
6
7
8 if (checkflag == false )
9 {
10
11 if (field.length == null )
12 {
13
14 field.checked = true ;
15 checkflag = true ;
16 // return false;
17
18 }
19
20 for (i = 0 ; i < field.length; i ++ )
21 {
22
23 field[i].checked = true ;
24 }
25 checkflag = true ;
26 // return "false";
27 } else
28 {
29
30 if (field.length == null )
31 {
32
33 field.checked = false ;
34 checkflag = false ;
35 // return true;
36
37 }
38 for (i = 0 ; i < field.length; i ++ )
39 {
40 field[i].checked = false ;
41 }
42 checkflag = false ;
43 // return true;
44 }
45 }
46 </ script >
47
48 < html >
49 < head >
50 < meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" >
51 < title > 无标题文档 </ title >
52 </ head >
53
54 < body >
55 < form name ="form1" method ="post" action ="" >
56 < p >
57 < input type ="checkbox" name ="ckbox" value ="checkbox" >
58 dfg </ p >
59 < p >
60 < input type ="checkbox" name ="ckbox" value ="checkbox" >
61 dfg
62 </ p >
63 < p >< br >
64 < input type ="checkbox" name ="全选" onClick ="this.value=check(this.form.ckbox)" >
65 全选 </ p >
66 < p > </ p >
67 </ form >
68 </ body >
69 </ html >
70