通过JQUERY,JSON,C#将复选框值转换为db

时间:2014-11-20 05:45:28

标签: javascript c# jquery asp.net json

我有以下代码: ASP.NET:

<body>
<form id="frm" runat="server">

    <asp:Panel ID="pnl_seat" runat="server">
        <asp:PlaceHolder ID="plhdr_seat" runat="server">
     <table>
        <tr>
            <td>dynamic checkbox controls generated with ids such as check_0, check_1...</td>
        </tr>
    </table>
   </asp:PlaceHolder>
        <br />
        <asp:Button ID="btn_submit" runat="server" Text="Submit"  />
    </asp:Panel>
    <div id="results"></div>
</form>

JQUERY:

    $(document).ready(function () {
        $("btn_submit").click(function () {
            x = $("frm").serializeArray();
            $.each(x, function (i, field) {
                $("#results").append(field.name + ":" + field.value + " ");
            });
        });
    });

我希望div中的输出为check_0:checked或check_0:true。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

试试这个:

    $(document).ready(function () {
        $("#btn_submit").click(function () { // add the # for id selector
            x = $("#frm").serializeArray();  // here too.
            $.each(x, function (i, field) {
                $("#results").append(field.name + ":" + field.value + " ");
            });
        });
    });