首页 > 代码库 > 多组 RadioButtonList 获取值

多组 RadioButtonList 获取值


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

</script>

多组 RadioButtonList 获取值