阅读从ASP选定的值:单选按钮列表使用jQuery [英] Reading the selected value from asp:RadioButtonList using jQuery
问题描述
我有类似下面的code ...
I've got code similar to the following...
<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>
我想捕捉当无线电名单blBuffetMealFacilities事件:CHK改变客户端,并从jQuery的的HasBuffet格执行滑下功能。什么是创造最好的办法,铭记存在的页面,在这里我想这取决于在电台列表中是没有答案的揭晓问题上几个类似的部分。
I want to capture an event when the radio list blBuffetMealFacilities:chk changes client side and perform a slide down function on the HasBuffet div from jQuery. What's the best way to create this, bearing in mind there are several similar sections on the page, where I want questions to be revealed depending on a yes no answer in a radio list.
推荐答案
这样的:
$('#rblDiv input').click(function(){
alert($('#rblDiv input').index(this));
});
将让你被点击的单选按钮(我认为,未经测试)的索引(注意你不得不包装你的RBL中#rblDiv
will get you the index of the radio button that was clicked (i think, untested) (note you've had to wrap your RBL in #rblDiv
然后你可以用它来显示这样相应的分区:
you could then use that to display the corresponding div like this:
$('.divCollection div:eq(' + $('#rblDiv input').index(this) +')').show();
那是你的意思?
编辑:另一种方法是给RBL类名,然后去:
Another approach would be to give the rbl a class name, then go:
$('.rblClass').val();
这篇关于阅读从ASP选定的值:单选按钮列表使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!