本文主要是介绍JS如何获取RadiobuttonList的选中值,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
JS代码:
<script language="javascript" type="text/javascript"> function RadioButtonList1Changed() { var vRbtid = document.getElementById("RadioButtonList1"); //得到所有radio var vRbtidList = vRbtid.getElementsByTagName("INPUT"); for (var i = 0; i < vRbtidList.length; i++) { if (vRbtidList[i].checked) { var text = vRbtid.cells[i].innerText; var value = vRbtidList[i].value; alert("选中项的text值为" + text + ",value值为" + value); } } } </script>
HTML:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" onClick="return RadioButtonList1Changed()"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:RadioButtonList>
这篇关于JS如何获取RadiobuttonList的选中值的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!