If you're talking about the same general code you posted in your other question, I believe you have to loop through the possible radiobuttons; there's no built-in whichRadioButtonIsSelected() function.
You could do something like this:
function getRadioButtonValue(rbutton)
{
for (var i = 0; i < rbutton.length; ++i)
{
if (rbutton[i].checked)
return rbutton.value;
}
return null;
}
// then in your code, where "this" is the form object, and
var rbvalue = getRadioButtonValue(this.radiobutton);
// replace "radiobutton" with whatever the radiobutton group's name is
edit: here's an example:
<html>
<head>
<style type="text/css">
body { background-color: black; color: white; }
</style>
<script type="text/javascript">
function getRadioButtonValue(rbutton)
{
for (var i = 0; i < rbutton.length; ++i)
{
if (rbutton[i].checked)
return rbutton[i].value;
}
return null;
}
function handleClick(event)
{
if (console) console.info("handling click");
// for Firebug debugging, if you want it
/* do something here */
alert(this.textBox1.value);
alert("Favorite weird creature: "+getRadioButtonValue(this["whichThing"]));
// I don't like alerts but it works everywhere
if (console) console.info("handled click");
event.preventDefault(); // disable normal form submit behavior
return false; // prevent further bubbling of event
}
function doit()
{
if (console) console.info("starting doit()");
document.forms.myform.addEventListener("submit", handleClick, true);
return true;
}
</script>
</head>
<body onload="doit()">
<form name="myform">
<div>
<textarea name="textBox1" rows="10" cols="80">
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.
</textarea>
</div>
<input type="submit" value="Update"/>
Which of the following do you like best?
<p><input type="radio" name="whichThing" value="slithy toves" />Slithy toves</p>
<p><input type="radio" name="whichThing" value="borogoves" />Borogoves</p>
<p><input type="radio" name="whichThing" value="mome raths" />Mome raths</p>
</form>
</body>
</html>