dig*_*uru 41 asp.net jquery event-handling radio-button
我有类似下面的代码......
<p><label>Do you have buffet facilities?</label>
<asp:RadioButtonList ID="blnBuffetMealFacilities:chk" runat="server">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList></p>
<div id="HasBuffet">
<p><label>What is the capacity for the buffet?</label>
<asp:RadioButtonList ID="radBuffetCapacity" runat="server">
<asp:ListItem Text="Suitable for upto 30 guests" value="0 to 30"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 50 guests" value="30 to 50"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 75 guests" value="50 to 75"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 100 guests" value="75 to 100"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 150 guests" value="100 to 150"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 250 guests" value="150 to 250"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 400 guests" value="250 to 400"></asp:ListItem>
</asp:RadioButtonList></p>
</div>
Run Code Online (Sandbox Code Playgroud)
当广播列表blBuffetMealFacilities:chk改变客户端并从jQuery对HasBuffet div执行向下滑动功能时,我想捕获一个事件.创建这个的最佳方法是什么,请记住页面上有几个类似的部分,我希望根据无线电列表中的"是"答案显示问题.
Vin*_*inh 81
检索RadioButtonList1的已检查值的简单方法是:
$('#RadioButtonList1 input:checked').val()
Run Code Online (Sandbox Code Playgroud)
蒂姆编辑:
其中RadioButtonList1必须是RadioButtonList的ClientID
var rblSelectedValue = $("#<%= RadioButtonList1.ClientID %> input:checked");
Run Code Online (Sandbox Code Playgroud)
And*_*ock 29
这个:
$('#rblDiv input').click(function(){
alert($('#rblDiv input').index(this));
});
Run Code Online (Sandbox Code Playgroud)
会得到你点击的单选按钮的索引(我认为,未经测试)(注意你必须将你的RBL包装在#rblDiv中)
然后你可以使用它来显示相应的div,如下所示:
$('.divCollection div:eq(' + $('#rblDiv input').index(this) +')').show();
Run Code Online (Sandbox Code Playgroud)
这是你的意思吗?
编辑:另一种方法是给rbl一个类名,然后去:
$('.rblClass').val();
Run Code Online (Sandbox Code Playgroud)
小智 11
这对我有用......
<asp:RadioButtonList runat="server" ID="Intent">
<asp:ListItem Value="Confirm">Yes!</asp:ListItem>
<asp:ListItem Value="Postpone">Not now</asp:ListItem>
<asp:ListItem Value="Decline">Never!</asp:ListItem>
</asp:RadioButtonList>
Run Code Online (Sandbox Code Playgroud)
处理程序:
$(document).ready(function () {
$("#<%=Intent.ClientID%>").change(function(){
var rbvalue = $("input[name='<%=Intent.UniqueID%>']:radio:checked").val();
if(rbvalue == "Confirm"){
alert("Woohoo, Thanks!");
} else if (rbvalue == "Postpone"){
alert("Well, I really hope it's soon");
} else if (rbvalue == "Decline"){
alert("Shucks!");
} else {
alert("How'd you get here? Who sent you?");
}
});
});
Run Code Online (Sandbox Code Playgroud)
重要的部分: $("input [name ='<%= Intent.UniqueID%>']:radio:checked").val();
小智 5
据我说它会工作得很好......
试试看吧
var GetValue=$('#radiobuttonListId').find(":checked").val();
Run Code Online (Sandbox Code Playgroud)
要存储在GetValue(变量)上的Radiobuttonlist值.
| 归档时间: |
|
| 查看次数: |
125137 次 |
| 最近记录: |