如何在JavaScript中的循环中检查所有复选框的状态 [英] How to check status of all the checkboxes in a loop in javascript

查看:102
本文介绍了如何在JavaScript中的循环中检查所有复选框的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在应用程序中使用母版页,
母版页的设计如下:

Hi,

I''m using Master pages in my application,
and the design of masterpage is like below:

<body id="bodyHomePage" runat="server" class="style12" onkeypress="return eval((event.keyCode==13)?false:true);">
    <form id="form1" runat="server" method="post" action="">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager2" EnablePartialRendering="false" EnableViewState="true" LoadScriptsBeforeUI="false"  runat="server"/>
    <div>
    <asp:UpdatePanel ID="updatePanelMaster" RenderMode="Block"    runat="server"><ContentTemplate>

        <table id="tdTable" runat="server" style="width:1240px;" cellspacing="0" cellpadding="0" align="center">
            <tr>
                <td id="main2" runat="server" valign="top" colspan="2">
                    <div id="main1" runat="server">
                        <uc2:WucTop ID="WucTop1" runat="server" />
                    </div>
                 </td>
            </tr>
            <tr>
                <td id="left1" runat="server"  valign="top">
                    <uc1:WucLeft ID="WucLeft1" runat="server" />
                </td>
                <td id="tdContent" runat="server" style="width:1050px" align="left" valign="top">
                    <table cellspacing="0" cellpadding="0" >
                        <tr>
                            <td valign="top" >
                                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                                </asp:ContentPlaceHolder>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" id="bottom1" runat="server">
                                <uc3:WucBottom ID="WucBottom" runat="server" />
                            </td>
                        </tr>
                    </table>
                </td>

            </tr>




        </table>
        </ContentTemplate></asp:UpdatePanel>
    </div>
    </form>
</body>




我的内容页面正在加载到"Contentplaceholder1".
现在我想要的是如何检查javascript页面中所有复选框的状态.

我已经尝试过了
for(i = 0; i< document.formName.elements.length; i ++){

但没有用(我无法在循环中获取表单名称)

请帮帮我.

谢谢&问候




my content page is loading in to "Contentplaceholder1".
Now what I want is how to check the status of all the checkboxes in a page in javascript.

I have tried like this
for(i=0; i<document.formName.elements.length; i++){

but no use (i''m unable to get form name in the loop)

Please help me.

thanks & regards

推荐答案

看看类似的文章: http://www.sajithmr.me/check-all-checkboxes-javascript/ [ jQuery:复选框选择器 [ ^ ]
Have a look at similar article: http://www.sajithmr.me/check-all-checkboxes-javascript/[^]

All you need is to either loop through all the controls of the form and check for the type to move ahead

OR if you are fine with using jQuery then you can use jQuery to directly pick all the checkboxes and then you can move ahead.
jQuery: Checkbox selector[^]


这篇关于如何在JavaScript中的循环中检查所有复选框的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆