• JS单选、复选问题。并得到选中行的值


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function checkbox()
    {  
     var str=document.getElementsByName("ckbSelectAllOne");
     var objarray=str.length;
     var chestr="";
     
     for(i=0;i<objarray;i++)
     {
      if(str[i].checked == true)
      {
       chestr+=str[i].value+",";
      }
     }
     if(chestr == "")
     {
       alert("请选择您所需修改状态行的复选框!");
     }
     else
     {
     chestr = chestr.substring(0,chestr.length-1);
       alert("复选框的值是:"+chestr);
     }
    }

    function SelectAllCheckBox()
    {
     var ckAllObj = document.getElementsByName("ckbSelectAll")[0];
     var ckOneObj=document.getElementsByName("ckbSelectAllOne");
     if(ckAllObj.checked)
     {
      for(i=0;i<ckOneObj.length;i++)
      {
       ckOneObj[i].checked = true;
      }
     }
     else
     {
      for(i=0;i<ckOneObj.length;i++)
      {
       ckOneObj[i].checked = false;
      }
     }
    }
    </script>
    </head>
    <body>
    <table id="DGInfo" cellspacing="0" cellpadding="3" border="1" style="WIDTH:100%;BORDER-COLLAPSE:collapse" borderColor="#9abceb"><tr bgColor="#d0e0f7"><td style="5%">
    <input id="ckbSelectAll" type="checkbox" name="ckbSelectAll" value="1065" onclick="SelectAllCheckBox()" />
    </td><td align="center" style="FONT-WEIGHT:bold; white-space:nowrap;">警告内容</td><td align="center" style="FONT-WEIGHT:bold">警告时间</td><td align="center" style="FONT-WEIGHT:bold">警告级别(最高3)</td><td align="center" style="FONT-WEIGHT:bold">处理状态</td></tr><tr><td><input id="ckbSelectAllOne__ctl0" type="checkbox" name="ckbSelectAllOne" value="1065"><INPUT id="HiddID" type="hidden" value="1065">1</td><td align="left">机器断线警告</td><td align="left">2010-06-07 20:58:43.000</td><td align="center">1</td><td align="center">0</td></tr><tr><td><input id="ckbSelectAllOne__ctl1" type="checkbox" name="ckbSelectAllOne" value="1041"><INPUT id="HiddID" type="hidden" value="1041">2</td><td align="left">机器断线警告</td><td align="left">2010-06-07 10:44:29.000</td><td align="center">1</td><td align="center">0</td></tr><t
    r><td><input id="ckbSelectAllOne__ctl2" type="checkbox" name="ckbSelectAllOne" value="49"><INPUT id="HiddID" type="hidden" value="49">3</td><td align="left">机器断线警告</td><td align="left">2010-04-26 22:48:32.000</td><td align="center">1</td><td align="center">0</td></tr></table>
    <input type="button" name="button" id="button" onclick="checkbox()" value="提交" />
    <input type="button" name="button" id="button" onclick="checkbox()" value="test" disabled="disabled" />
    </body>
    </html>

  • 相关阅读:
    Javascript--普通函数调用-涨工资计算函数
    Javascript--运算符判断成绩运算
    Javascript-闰年javascript的判断
    Javascript-逻辑判断或(&&)练习
    Javascript-短路 与(&&)
    UVALive6434_Number Assignment
    HDU4811_Ball
    HDU4810_Wall Painting
    HDU4803_Poor Warehouse Keeper
    HDU4802_GPA
  • 原文地址:https://www.cnblogs.com/xiaoai/p/1771175.html
Copyright © 2020-2023  润新知