Code demonstration of JavaScript select all and cancel all

From , 3 Years ago, written in JavaScript, viewed 127 times.
URL https://pastebin.vip/view/07b2ee9f
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  4. <title>无标题文档</title>
  5. <script type="text/javascript" language="javascript">
  6. function selectAll()
  7. {
  8. var allCheckBoxs = document.getElementsByName("coffee");
  9. var desc = document.getElementById("like");
  10. if(desc.value == "都喜欢")
  11. {
  12. desc.value = "都不喜欢";
  13. for(var i = 0; i < allCheckBoxs.length; i ++ )
  14. {
  15. allCheckBoxs[i].checked = true;
  16. }
  17. }
  18. else
  19. {
  20. desc.value = "都喜欢";
  21. for(var i = 0; i < allCheckBoxs.length; i ++ )
  22. {
  23. allCheckBoxs[i].checked = false;
  24. }
  25. }
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <p>你喜欢那种类型咖啡</p>
  31. <form>
  32. <input type="checkbox" name="coffee" value="cream">蓝山咖啡<br>
  33. <input type="checkbox" name="coffee" value="sugar" >摩卡<br>
  34. <input type="checkbox" name="coffee" value="sugar">拿铁<br>
  35. <input type="checkbox" name="coffee" value="sugar">卡布奇诺<br>
  36. <input type="checkbox" name="coffee" value="sugar">爱尔兰咖啡<br>
  37. <input type="button" id="like" value="都喜欢" onClick="selectAll()">
  38. </form>
  39. </body>
  40. </html>
  41. //javascript/6002

Reply to "Code demonstration of JavaScript select all and cancel all"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website