zoukankan      html  css  js  c++  java
  • 关于(控制表单多选框可供选择的个数)

    ---恢复内容开始---

    1.代码段:

    <head>
    <meta charset="UTF-8">
    <title>控制表单多选框可供选择的个数</title>
    <meta http-equiv="content-type" content="text/html;charset=gb2312">
    <script language=javascript>
    function choosepro(aa){
     var checkCount = 3;//最多可以选择3个
     var iTemp = 0;
     var len = document.getElementsByTagName("input");
     if(len.length){
      for(var i=0;i<len.length;i++){
       if(len[i].checked){
        iTemp++;
        if(checkCount<iTemp){
         alert("您选的商品不能大于"+checkCount+"件!");
         aa.checked=false;
         return;
        }
       }
      }
     }else{
      if(len.checked){
       iTemp++;
       if(checkCount<iTemp){
        alert("您选的商品不能大于"+checkCount+"件!");
        aa.checked=false;
        return;
       }
      }
     }
    }
    </script>
    </head>
    <body>
    <input type="checkbox" name="toDelGWCProID[1][]" value="1" onClick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="2" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="3" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="4" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="5" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="6" onClick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="7" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="8" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="9" onclick="choosepro(this)">
    <input type="checkbox" name="toDelGWCProID[1][]" value="10" onclick="choosepro(this)">
    </body>

    结果:自己看吧

      

  • 相关阅读:
    各种数字证书区别
    微信支付前端对接流程
    ts笔记 流动类型
    支付宝支付前端对接流程
    ts笔记索引签名
    [翻译]Selenium API 命令和操作(JAVA)
    玩一玩yolo目标检测
    快速上手MyBatis
    Swift快速入门
    Windows远程桌面后不能粘贴问题处理
  • 原文地址:https://www.cnblogs.com/momox/p/6049934.html
Copyright © 2011-2022 走看看