我有一个Javascript函数,根据RadioButtonList中选择的值执行不同的操作:
<asp:RadioButtonList ID="rbtLocation" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Table" onclick="javascript:Setup()">
<asp:ListItem Selected="First" Text="First" Value="First"></asp:ListItem>
<asp:ListItem Text="Second" Value="Second"></asp:ListItem>
</asp:RadioButtonList>
我的javascript函数:
function Setup()
{
var radioButtons = document.getElementsByName("<%=rbtLocation.ClientID%>");
for (var x = 0; x < radioButtons.length; x++)
{
if (radioButtons[x].checked)
{
alert("You checked " + radioButtons[x].id + " which has the value " + radioButtons[x].value);
if (value == "First")
{
alert("Do this");
}
else
{
alert("Do that");
}
}
}
}
但是从不执行if语句if(radioButtons [x] .checked)的内容。我检查了一些来源,但在我的代码中看不到错误。
答案 0 :(得分:1)
根据此修改你的javascript函数。
功能设置(){
***^|^100^|^101^|^102^|^103^|^104^|^