0

吉日

刚刚学习 jquery UI,今天取得了一些非常好的进展,但是在弄清楚如何在提交表单之前在按钮集中获取所选按钮的 ID 时遇到了困难。

一旦获得所选按钮的 ID,我就知道如何使 AJAX POST 工作。

第一部分是如何完成的?

这是我的jQuery:

$( "#pi" ).buttonset();


    $( "#req1" ).dialog({           

        resizable: false,
        height:350,
        minWidth: 310,
        modal: true,
        buttons: {
            "Send request": function() {


                     //what goes here to retrieve the ID of the selected button?


                $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }
    });

还有我的表格...

<div id="req1" title="make your selection:">

<form>
<div id="pi">
    <input type="radio" id="p1" name="pi" /><label for="p1">3</label>
    <input type="radio" id="p2" name="pi" /><label for="p2">2</label>
    <input type="radio" id="p3" name="pi" /><label for="p3">1</label>
    <input type="radio" id="p4" name="pi" checked="checked" /><label for="p4">0</label>
    <input type="radio" id="p5" name="pi" /><label for="p5">1</label>
    <input type="radio" id="p6" name="pi" /><label for="p6">2</label>
    <input type="radio" id="p7" name="pi" /><label for="p7">3</label>
</div>

感谢您的时间和帮助。

4

1 回答 1

0

尝试这个:

var id = $('#pi input[name=pi]:checked').attr('id');
于 2012-09-30T06:24:23.357 回答