0

aspx 脚本:

<script type="text/javascript">
    $(document).ready(function() {
        $(".div_soru").hide();
        $(".div_soru").first().show();
        $(".onceki").click(function() {
            if ($(this).closest(".div_soru").prev(".div_soru").html() != null) {
                $(this).closest(".div_soru").hide();
                $(this).closest(".div_soru").prev().show();
                $(".bitir").hide();
                $(".sonraki").show();
            }
        });
        $(".sonraki").click(function() {
            if ($(this).closest(".div_soru").next(".div_soru").html() != null) {
                $(this).closest(".div_soru").hide();
                $(this).closest(".div_soru").next().show();
                if ($(this).closest(".div_soru").next().next().html() == null) {
                    $(".bitir").show();
                    $(".sonraki").hide();
                }
            }
        });
    });
</script>

和aspx:

<asp:Repeater ID="Repeater_sorular" runat="server" OnItemDataBound="Repeater_sorular_OnItemDataBound"
            OnItemCommand="Repeater_sorular_ItemCommand">
    <HeaderTemplate>
    </HeaderTemplate>
    <ItemTemplate>
         <div class="div_soru">
             <div class="div_soru_wrapper">
                 <div style="font-weight: bolder; padding: 5px;">
                    (<%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>
                    /
                    <%# Eval("SoruSayisi")%>)
                    <%#Eval("Subject")%>
                 </div>
                 <asp:RadioButtonList ID="RadioButtonList_secenekler" runat="server" Visible='<%# Eval("TypeId").ToString() == "2" %>'
                    DataSource='<%#Eval("Secenekler")%>' DataTextField="OptionName" DataValueField="OptionId">
                 </asp:RadioButtonList>
                 <asp:CheckBoxList ID="CheckBoxList_secenekler" runat="server" Visible='<%# Eval("TypeId").ToString() == "1" %>'
                    DataSource='<%#Eval("Secenekler")%>' DataTextField="OptionName" DataValueField="OptionId">
                 </asp:CheckBoxList>
              </div>
              <div class="div_nav_buttons">
                  <table>
                      <tr>
                            <td id="onceki" class="onceki">
                                <img src="../Img/adminicons/geri.gif" />
                            </td>
                            <td id="sonraki" class="sonraki">
                                <img src="../Img/adminicons/ileri.gif" />
                            </td>
                            <td id="bitir" class="bitir">
                                <asp:ImageButton ID="ImageButton_kaydet" runat="server" CommandName="kaydet" ImageUrl="~/Img/adminicons/kaydet.gif"
                                        CommandArgument='<%# Container.ItemIndex %>' OnClientClick="return confirm('Anketi kaydetmek istediğinize emin misiniz?');" />
                            </td>
                      </tr>
                 </table>
            </div>
        </div>
    </ItemTemplate>
    <FooterTemplate>
    </FooterTemplate>
</asp:Repeater>

此脚本隐藏广播组。我使用下一个和上一个按钮一一展示。如果未选择无线电组之一中的无线电,我想显示一条错误消息。我如何才能当前单选组选定的值。

我试试这个,但这是从第一个无线电组获得无线电价值。

var selectedRadios = $(".div_soru_wrapper input:radio:checked").val();

我想我无法解释清楚。我希望你明白我想做什么:) 谢谢。

4

1 回答 1

1

如果您想检查当前可见组中是否有选中的单选按钮,:visible选择器可以帮助您:

if ($(".div_soru_wrapper:visible input:radio:checked").length) {
    // There is a checked radio button in the currently visible group.
} else {
    // There is no checked radio button in the currently visible group.
}
于 2012-06-19T09:12:51.263 回答