Hi there,
Unfortunately, there isn't an easier way. You'll have to loop through all
the radiobuttons with the same name, and then see if they are checked or not.
Here is an example:
var frmForm = document.frmFormula;
var len = frmForm.elements.length;
for (var i = 0 ; i < len ; i++)
{
if (frmForm.elements[i].name == 'chkFormula')
{
if (frmForm.elements[i].checked == true)
{
alert(frmForm.elements[i].value);
}
}
}
This loops through ALL the fields in the form. If the name is chkFormula it
checks whether the item is selected or not.
You could minimize this code by not looping through the complete form, but
by using document.getElementsByName("myName"), which returns a collection
of all elements with the name "myName". Note, however, that you need a
rather modern browser for this method to work.
HtH
Imar
At 10:21 AM 11/14/2001 -0800, you wrote:
>I can't figure out how to see the value of radio buttons. I have a group of
>radio buttons all named the same, and I want to know which one is checked.
>Can anybody explain this or point me in the right direction? I've done this
>before by putting different ID's on all of them, then checking each one
>separately. There's got to be a better way. When I say
>"form.radiobuttonname.value" I get an error. I haven't messed with radio
>buttons with javascript in a really long time and I'm lost.
>
>
>Thanks,
>Cory Harrison
>Internet Developer
>Computer Services Inc.
>charrison@c...
>(270) 442-7361 x10643
>
>