Checking the radio buttons I

This script shows how to use the Radio object properties to determine which radio button is checked. This is done by clicking the "select color" button.

Select a color

blue
green
red
yellow
black
white

HTML
<form name="colorSel" action="">
<input type="radio" name="sRadio" value="blue" /> blue <br />
<input type="radio" name="sRadio" value="green" /> green <br />
<input type="radio" name="sRadio" value="red" /> red <br />
<input type="radio" name="sRadio" value="yellow" /> yellow <br />
<input type="radio" name="sRadio" value="black" /> black <br />
<input type="radio" name="sRadio" value="white" checked="checked" /> white
<p>
<input type="button" value="select color" onclick="selColor()"></p>
</form>

JavaScript
<script type="text/javascript">
function selColor()
{
  var radioNum = document.colorSel.sRadio.length;
  for (i=0; i<6; i++)
  {
   if (document.colorSel.sRadio[i].checked)
   {
    var color = document.colorSel.sRadio[i].value;
    alert("Selected color is: " + color);
   }
  }
}
</script>