Home  >  Article  >  Web Front-end  >  js获取RadioButtonList的Value/Text及选中值等信息实现代码_javascript技巧

js获取RadioButtonList的Value/Text及选中值等信息实现代码_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:41:041346browse

HTML代码

复制代码 代码如下:

RepeatColumns="4" RepeatDirection="horizontal">
asp:ListItem>
asp:ListItem>
asp:ListItem>
asp:ListItem>


JS代码:
复制代码 代码如下:

function RadioButtonList1Changed()
{
var rbtn = document.getElementByIdx_x("rbtnCompany");
//得到所有radio
var list= rbtn .getElementsByTagName_r("input");
for (var i = 0; i if (vRbtidList[i].checked) {
var text = rbtn .cells[i].innerText;
var value = list[i].value;
alert("选中项的text值为" + text + ",value值为" + value);
}
}
}

可以指定获取某个值 ,下面的语句是合并写的。获取索引为0的第一项的value
复制代码 代码如下:

alert(document.getElementByIdx_x("rbtnCompany").getElementsByTagName_r("input")[0].value);//结果为1
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn