bobleny
08-20-2011, 01:04 AM
I have this function:
function SelectedRadio(form, name)
{
for(var i = 0; i < form.name.length; i++)
{
if(form.name[i].checked == true)
{
return form.name[i].value;
}
}
return "Error!";
}
Form is a form object, and name is a string of the name of the radio button.
I thought it was trying to use the variable name as the name of a field. For example:
function OnFormSubmit(form)
{
SelectedRadio(form, "fruits")
}
Instead of form.fruits its using form.name. Basically I am trying to use the variable as a string.
Is there anyway around this?
function SelectedRadio(form, name)
{
for(var i = 0; i < form.name.length; i++)
{
if(form.name[i].checked == true)
{
return form.name[i].value;
}
}
return "Error!";
}
Form is a form object, and name is a string of the name of the radio button.
I thought it was trying to use the variable name as the name of a field. For example:
function OnFormSubmit(form)
{
SelectedRadio(form, "fruits")
}
Instead of form.fruits its using form.name. Basically I am trying to use the variable as a string.
Is there anyway around this?