js 判斷項目中CheckBox 是否選中

<!--js部分-->    

<script type="text/javascript">

        function aa() {
            var b = false;
            var objs = document.getElementsByName("ids");
            var a = 0;
            var val = "";
            for (var i = 0; i < objs.length; i++) {
                if (objs[i].checked) {
                    if (a <= 0) {
                        b = true;
                        val = objs[i].value
                        a = a + 1;
                        
                        document.getElementById("aaa").href = "Customers/CustomerAction.aspx?id=" + val;
                    }
                    if (a > 2) {
                        alert('只能選中一個廠商');
                    }
                }


            }
            if (a == 0) {
                alert('請選擇一個廠商');
                navTab.reload();
            }
        }

    </script>

<!--Html 部分-->

   <div class="pageContent">
   <div class="panelBar">
   
   </div>
   <table class="table" width="100%" layoutH="138">
   <thead>
   <tr>
   <th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                    <th width="50" class = "id" >供應商編號</th>
   <th  align="center" class="style1">供應商名稱</th>
                    <th width="100" align="center">城市</th>
                    <th width="100" align="center">區縣</th>
                    <th width="100" align="center">客戶類型</th>
   </tr>
   </thead>
   <tbody>
                <asp:Repeater ID="RepeaterTr" runat="server" >
                    <ItemTemplate>
                        <tr target="sid_user">
                            <td><input name="ids" type="checkbox" value="<%#DataBinder.Eval(Container.DataItem, "id")%>" /></td>
                            <!--中文名稱、英文名稱、圖片地址-->
                            <td> <%#DataBinder.Eval(Container.DataItem, "id")%></td>
                            <td> <%#DataBinder.Eval(Container.DataItem, "customername")%></td>
                            <td> <%#DataBinder.Eval(Container.DataItem, "provice")%></td>
                            <td> <%#DataBinder.Eval(Container.DataItem, "city")%></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>            
                </tbody>
   </table>

        </div>
    </div>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章