多组 RadioButtonList 获取值


<div class="row">
    <table>
        <thead><tr><th>操作</th></tr></thead>
        <tbody>
            <tr>
                <td>
                    <input type="radio" name="3" value="Update" />覆盖
                    <input type="radio" name="3" value="Insert" />更新
                    <input type="radio" name="3" value="Cancel" />取消
                </td>
            </tr>
            <tr>
                <td>
                    <input type="radio" name="2" value="Update" />覆盖
                    <input type="radio" name="2" value="Insert" />更新
                    <input type="radio" name="2" value="Cancel" />取消
                </td>
            </tr>
            <tr>
                <td>
                    <input type="radio" name="5" value="Update" />覆盖
                    <input type="radio" name="5" value="Insert" />更新
                    <input type="radio" name="5" value="Cancel" />取消
                </td>
            </tr>
        </tbody>
    </table>
    <input type="button" id="btnTry" value="更新" />
</div>
<script type="text/javascript" src="~/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    jQuery("#btnTry").click(function () {
        var updateIds = '';
        $('input:radio[value="Update"]:checked').each(function (i, val) {
            updateIds += val.name+';';
        });
        var insertIds = '';
        $('input:radio[value="Insert"]:checked').each(function (i, val) {
            insertIds += val.name + ';';
        });
        alert('Update:'+updateIds);
        alert('Insert:'+insertIds);
    });

</script>

posted @ 2016-10-12 09:20  jimcsharp  阅读(205)  评论(0编辑  收藏  举报