Code:
<HTML>
<HEAD>
<META http-equiv="Content-Language" content="en-us">
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE>Number of Input tags</TITLE>
<SCRIPT>
function countQ()
{
ContainerElement=document.getElementById("container")
RadioCollection=ContainerElement.getElementsByTagName('INPUT');
document.getElementById('inputNO').value=RadioCollection.length
return RadioCollection.length
}
function appendRadioSet()
{
var newName=countQ()/4
ContainerElement=document.getElementById("container")
RadioSet=document.createElement("P");
RadioSet.innerHTML='<INPUT type=radio checked name=R'+newName+'><INPUT type=radio name=R'+newName+'><INPUT type=radio name=R'+newName+'><INPUT type=radio name=R'+newName+'>'
ContainerElement.appendChild(RadioSet)
countQ()
}
</SCRIPT>
</HEAD>
<BODY onload=" countQ()">
<INPUT type="button" onclick="appendRadioSet()" value="Add radio set">
<INPUT type="text" id="inputNO" size="20"> Number of Input tags
<DIV id="container">
<P><INPUT type="radio" checked name="R1"><INPUT type="radio" name="R1"><INPUT type="radio" name="R1"><INPUT type="radio" name="R1"></P>
<P><INPUT type="radio" name="R2"><INPUT type="radio" checked name="R2"><INPUT type="radio" name="R2"><INPUT type="radio" name="R2"></P>
<P><INPUT type="radio" name="R3"><INPUT type="radio" name="R3"><INPUT type="radio" checked name="R3"><INPUT type="radio" name="R3"></P>
<P><INPUT type="radio" name="R4"><INPUT type="radio" name="R4"><INPUT type="radio" name="R4"><INPUT type="radio" checked name="R4"></P>
</DIV>
</BODY>
</HTML>