复选框全选、全不选和反选的效果实现VIEW:1592

 
 
  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
  4. <title>复选框全选、全不选和反选的效果实现</title>
  5. <SCRIPTLANGUAGE="JavaScript">
  6. <!--Begin
  7. functioncheckAll(){
  8. for(varj=1;j<=9;j++){
  9. box=eval("document.checkboxform.C"+j);
  10. if(box.checked==false)box.checked=true;
  11. }
  12. }
  13. functionuncheckAll(){
  14. for(varj=1;j<=9;j++){
  15. box=eval("document.checkboxform.C"+j);
  16. if(box.checked==true)box.checked=false;
  17. }
  18. }
  19. functionswitchAll(){
  20. for(varj=1;j<=9;j++){
  21. box=eval("document.checkboxform.C"+j);
  22. box.checked=!box.checked;
  23. }
  24. }
  25. //End-->
  26. </script>
  27. </head>
  28. <body>
  29. <formname=checkboxform>
  30. <inputtype=checkboxname=C1checked>C1<br>
  31. <inputtype=checkboxname=C2checked>C2<br>
  32. <inputtype=checkboxname=C3checked>C3<br>
  33. <inputtype=checkboxname=C4checked>C4<br>
  34. <inputtype=checkboxname=C5checked>C5<br>
  35. <inputtype=checkboxname=C6checked>C6<br>
  36. <inputtype=checkboxname=C7checked>C7<br>
  37. <inputtype=checkboxname=C8checked>C8<br>
  38. <inputtype=checkboxname=C9checked>C9<br>
  39. <br>
  40. <inputtype=buttonvalue="全部选中"onClick="checkAll()"><br>
  41. <inputtype=buttonvalue="全部不选"onClick="uncheckAll()"><br>
  42. <inputtype=buttonvalue="选择转换"onClick="switchAll()"><br>
  43. </form>
  44. </body>
  45. </html>

你可能感兴趣的:(view)