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>
此脚本隐藏广播组。然后我使用next和prev按钮逐个显示它们。 如果未选择某个无线电gruop中的无线电,我想显示错误消息。我当前如何选择当前的无线电组。
我试试这个,但这是从第一个广播组获得无线电值。
var selectedRadios = $(".div_soru_wrapper input:radio:checked").val();
我想我无法解释清楚。我希望你明白我想做什么:) 感谢。
答案 0 :(得分: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.
}