This is a very short, simple piece of code with a form and a Javascript function:
Code:
<script type="text/javascript" language="JavaScript">

function doSwitch()
{
	if (frm.radIsCode[1].checked == true)
	{
		frm.radAddCode[0].disabled = true;
		frm.radAddCode[1].disabled = true;
	}
	
	else
	{
		frm.radAddCode[0].disabled = false;
		frm.radAddCode[1].disabled = false;
	}
}

</script>


<form id="frm" name="frm">
	<input type="radio" id="radIsCode" name="radIsCode" value="Y" checked="checked" onclick="doSwitch();" />Yes
	<input type="radio" id="radIsCode" name="radIsCode" value="N" onclick="doSwitch();" />No
	
	<input type="radio" id="radAddCode" name="radAddCode" value="Y" checked="checked" />Yes
	<input type="radio" id="radAddCode" name="radAddCode" value="N" />No
</form>

In the interests of XHTML I have written my HTML code to use both ids and names and for them to be the same value.
I have found that when I start using JavaScript, as in the simple example above, that I then appear to have to index the radio buttons e.g. [0] or [1], obviously this is not terribly meaningful and if for some reason I ever had to change the order of the radio buttons I could potentially have to change all the index values in my code as well.
Is there some way of refering to these buttons by their values?
I would like to be able to put something like
Code:
if (frm.radIsCode.value == 'Y')
Can anyone offer me advise on this?