Hello,
I have a function that I call that tells me the checked value of a group of radio boxes. You pass in the form name and radio group name and it gives you the value of the one that is checked.
I have a dynamic list of existing shipto addresses that a user can select one in order to have something shipped to a previously used shipto address. If I have more than one, my code works but if there is only one radio option and they click it, the object is deemed undefined. I need for this function to handle a single radio option on the page as it is possible in some cases.
Here is my code
[CODE]
function get_radio_checked_value( form_name, radio_name )
{
var radioObj = document.forms[ form_name ].elements[ radio_name ];
for(var i = 0; i < radioObj.length; i++)
{
if(radioObj[i].checked)
return radioObj[i].value;
}
}
And my usage is usually like this
[CODE]var tempradio = get_radio_checked_value( ‘frm_shipto’, ‘rad_shipto’ );
In the above example if I have more than one address / radio option, tempradio holds the correct value otherwise if just one address available it holds undefined
Any help would be greatly appreciated.