myapit

JS Maximum Checkbox Limit Second

Apr 5th, 2017
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <title></title>
  4. <META NAME="DESCRIPTION" CONTENT="">
  5. <META NAME="KEYWORDS" CONTENT="">
  6.  
  7. <script type="text/javascript">
  8. function chkcontrol(j) {
  9. var total=0;
  10. for(var i=0; i < document.form1.ckb.length; i++){
  11. if(document.form1.ckb[i].checked){
  12. total =total +1;}
  13. if(total > 3){
  14. alert("Please Select only three")
  15. document.form1.ckb[j].checked = false ;
  16. return false;
  17. }
  18. }
  19. } </script>
  20. </head>
  21.  
  22. <body  topmargin=''0'';  >
  23.  
  24.      <form name=form1 method=post action=check.php>
  25. <table border=''0'' width=''250'' cellspacing=''0'' cellpadding=''0'' align=center>
  26.  
  27.  
  28.  
  29. <tr bgcolor=''#ffffcc''><td > </td><td ><b>Choice</b></td></tr>
  30. <tr bgcolor=''#f1f1f1'' ><td ><input type=checkbox name=ckb value=1 onclick='chkcontrol(0)';></td><td >PHP</td></tr>
  31. <tr bgcolor=''#ffffff'' ><td ><input type=checkbox name=ckb value=2 onclick='chkcontrol(1)';></td><td >Perl</td></tr>
  32. <tr bgcolor=''#f1f1f1'' ><td ><input type=checkbox name=ckb value=3 onclick='chkcontrol(2)';></td><td >MySQL</td></tr>
  33. <tr bgcolor=''#ffffff'' ><td ><input type=checkbox name=ckb value=4 onclick='chkcontrol(3)';></td><td >ASP</td></tr>
  34. <tr bgcolor=''#f1f1f1'' ><td ><input type=checkbox name=ckb value=5 onclick='chkcontrol(4)';></td><td >JavaScript</td></tr>
  35. <tr bgcolor=''#ffffff'' ><td ><input type=checkbox name=ckb value=6 onclick='chkcontrol(5)';></td><td >CSS</td></tr>
  36. <tr bgcolor=''#f1f1f1'' ><td ><input type=checkbox name=ckb value=7 onclick='chkcontrol(6)';></td><td >HTML</td></tr>
  37. <tr bgcolor=''#ffffff'' ><td ><input type=checkbox name=ckb value=8 onclick='chkcontrol(7)';></td><td >Photo Shop</td></tr>
  38. </table></form>
  39. </body>
  40. </html>
Add Comment
Please, Sign In to add comment