Reputation:
I have an asp Radio Button List created this way:
ListItem item = new ListItem(string Id, string Name);
RadioButtonList1.Items.Add(item);
I can't manage to get the value of the selected item in javascript. The following is my code part:
var _rad = document.getElementByName('RadioButtonList1');
for (var j = 0; j < _rad.length; j++) {
if (_rad[j].checked) {
_index = _rad[j].value - 1;
}
}
Upvotes: 0
Views: 920
Reputation: 1484
try using jQuery.. that will be a lot easier
check this JS Binn sample.
http://jsbin.com/aviza5/2/edit
Upvotes: 1
Reputation: 147403
The method you seek is document.getElement*s*ByName(...), otherwise it should work.
Upvotes: 1