When the javascript implementation check box exceeds the limit, a warning box is displayed. The javascript check box
This article describes how to bring up a warning box when the check box of javascript is exceeded. Share it with you for your reference. The specific implementation method is as follows:
<Html> <title> how to bring up a warning box when the javascript implementation check box exceeds the limit </title> <body> <script language = "JavaScript"> <! -- // Function countChoices (obj) {max = 2; box1 = obj. form. box1.checked; box2 = obj. form. box2.checked; box3 = obj. form. box3.checked; count = (box1? 1: 0) + (box2? 1: 0) + (box3? 1: 0); if (count> max) {alert ("Sorry, you can only select" + max + "projects! "); Obj. checked = false ;}/// --> </script> <form name = "form"> select a maximum of two projects: <p> <input type = checkbox name = box1 onClick = "countChoices (this) "> select project 1 <p> <input type = checkbox name = box2 onClick =" countChoices (this) "> select project 2 <p> <input type = checkbox name = box3 onClick =" countChoices (this) "> select project 3 <p> <div> </FORM> </body>
I hope this article will help you design javascript programs.