我想从 javascript 中的 asp.net 单选按钮列表中获取选定的单选按钮。在文本框 onchange 事件中,我在下面编写了代码;
<asp:RadioButtonList CssClass="radioWithProperWrap"
ID="RadioButtonList1" runat="server" CellPadding="0"
CellSpacing="0" RepeatColumns="2" RepeatDirection="Horizontal"
>
<asp:ListItem Value="1" Selected="True">Aylık Ödeyeceğim Taksite Göre</asp:ListItem>
<asp:ListItem Value="2">Toplam Alacağım Krediye Göre</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="TempTxtBox" runat="server" onchange="myFun()" ></asp:TextBox>
和javascript;
<script language="javascript" type="text/javascript">
function myFun() {
var deger = document.getElementById('<%=TempTxtBox.ClientID%>').value;
var vade = document.getElementById('<%=MaturitytxtBox.ClientID%>').value;
var radioButtons = document.getElementsByName('<%=RadioButtonList1.ClientID%>');
var radio = radioButtons.item(0).checked;
alert(radio);
}
</script>
它不起作用..有人可以帮忙吗?