zoukankan      html  css  js  c++  java
  • js 全选

    <form name="frm" method="post" action="/add" onsubmit="return check()">
    <table class="titem" >
    <tr>
    <td class="field"> * 所属批次</td>
    <td class="value">
    <select name="stockmst_id" id="stockmst_id">
    {html_options options=$stockmst_arr selected=$stockmst_id}
    </select>
    </td>
    <td>
    &nbsp;&nbsp;<input type="submit" value="提交" id="Btn" />
    </td>
    <td>
    &nbsp;&nbsp;<input type="button" value="返回" onclick="javascript:document.location.href='list?';" />
    </td>
    </tr>
    </table>
    </form>
    {if $poList}
    <form action="/PurchaseOrderCleanLocation/doAdd" method="post" name="form1" onsubmit="return checkBoxSelect()">
    <table class="tlist">
    <thead>
    <tr class="title">
    <td><strong><input id="chkAll" type="checkbox" onclick="javascript:checkAll();">全选</strong></td>
    <td><strong>所属批次</strong></td>
    <td><strong>单号</strong></td>
    <td><strong>单名称</strong></td>
    <td><strong>类别</strong></td>
    <td><strong>状态</strong></td>
    </tr>
    </thead>
    <tbody>
    {foreach $poList as $key=>$tpc}
    <tr>
    <td>
    <input type="checkbox" name="pom_ids[]" onclick="javascript:checkChecked();" value="{$tpc.pom_id}" />
    </td>
    <td>{$tpc.pom_stock_name}</td>
    <td>{$tpc.pom_code}</td>
    <td>{$tpc.pom_name}</td>
    <td>{$tpc.pom_type_name}1</td>
    <td>{$tpc.pom_status}</td>
    </tr>
    {/foreach}
    <tr>
    <td align="left" colspan="6"><input type="submit" name="sub" value="提交" /></td>
    </tr>
    </tbody>
    </table>
    </form>
    {/if}
    <div>
    <script type="text/javascript">
    function checkBoxSelect(){
    var falg = 0;
    $(
    "input[name='pom_ids[]']:checkbox").each(function () {
    if ($(this).attr("checked")) {
    falg
    =1;
    return false;
    }
    })
    if (falg > 0)
    return true;
    else {
    alert(
    "亲,至少要选一项才能提交!");
    return false;
    }
    }
    function checkAll()
    {
    var objCheckAll = document.getElementById("chkAll");
    var arrObjInput = document.getElementsByTagName("input");
    for(intI = 0 ; intI < arrObjInput.length ; intI ++)
    {
    if(arrObjInput[intI].type == "checkbox" && arrObjInput[intI].id != "chkAll")
    {
    if(objCheckAll.checked == true )
    {
    arrObjInput[intI].checked
    = true;
    }
    else
    {
    arrObjInput[intI].checked
    = false;
    }
    }
    }
    }

    function checkChecked()
    {
    var objCheckAll = document.getElementById("chkAll");
    var arrObjInput = document.getElementsByTagName("input");
    var blnChecked = true;
    for(intI = 0 ; intI < arrObjInput.length ; intI ++)
    {
    if(arrObjInput[intI].type == "checkbox" && arrObjInput[intI].id != "chkAll")
    {
    if(arrObjInput[intI].checked == false)
    {
    blnChecked
    = false;
    }
    }
    }
    objCheckAll.checked
    = blnChecked;
    }
    </script>

    转载保留链接

  • 相关阅读:
    CUDA从入门到精通
    [Network] 计算机网络基础知识总结
    第三章 需求工程概论
    jsp学习
    算法——递推算法
    大话设计模式读书笔记--文章汇总
    轻松学SQL Server数据库
    Oracle数据库建表+添加数据练习
    《C#图解教程》 总览
    php发送get、post请求的6种方法简明总结
  • 原文地址:https://www.cnblogs.com/xwblog/p/2345032.html
Copyright © 2011-2022 走看看