onaled777
asked on
Length of a radio group being returned as undefined when there is only one radio button in the group
The radio.length value returns 'undefined' when there is only one value in a radio group.
I know it is not normal to have just one value in the radio group, but I find myself in that situation where the number of radio buttons in the group depends on the output of a query.
Anyone knows how I can work around this issue.
I know it is not normal to have just one value in the radio group, but I find myself in that situation where the number of radio buttons in the group depends on the output of a query.
Anyone knows how I can work around this issue.
JAVASCRIPT FUNCTION:
<script type="text/javascript">
function getRadioValue(radio) {
for(i=0; i<radio.length; i++) {
if(radio[i].checked) return radio[i].value;
}
return 0;
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
glad to help