日期:2014-05-17 浏览次数:20366 次
<asp:RadioButtonList runat="server" ID="rdoDiscount" RepeatLayout="Flow" RepeatDirection="Horizontal"> <asp:ListItem Value="1">折扣 </asp:ListItem> <asp:ListItem Value="2">价格 </asp:ListItem> </asp:RadioButtonList> <input type="button" onclick="haveChecked()?alert('已选择'):alert('未选择');" value="check" /> <script type="text/javascript"> function haveChecked() { var rbl=document.getElementById('<%=rdoDiscount.ClientID %>'); var rbls=rbl.getElementsByTagName('input'); for(var i=0;i<rbls.length;i++) { if(rbls[i].type=='radio') if(rbls[i].checked) return true; } return false; } </script>
------解决方案--------------------
改进一下
<asp:RadioButtonList runat="server" ID="rdoDiscount" RepeatLayout="Flow" RepeatDirection="Horizontal"> <asp:ListItem Value="1">折扣 </asp:ListItem> <asp:ListItem Value="2">价格 </asp:ListItem> </asp:RadioButtonList> <input type