您的位置:首页 > Web前端 > JavaScript

JS如何获取RadiobuttonList的选中值

2013-03-20 09:07 369 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: