Which Radio Choosen

[Total: 0    Average: 0/5]

This shows how to determine which item in a radio selection is choosen.

Body Code:

<script language="javascript">
var x,b
function joe()
{


if   (document.formi.rad.value!="")
{ x=document.formi.texti.value
for(i=0;i<document.formi.rad.length;i++)
if(document.formi.rad[i].checked==true)
{b=(x+(document.formi.rad[i].value))}
 document.formi.texti.value=b
}
else
for(i=0;i<document.formi.rad.length;i++)
if(document.formi.rad[i].checked==true)
 document.formi.texti.value=document.formi.rad[i].value
}
</script>
<form name=formi>
Select an operating system<br>
<input type=radio name=rad value=a onclick=joe()>a<br>
<input type=radio name=rad value=b onclick=joe()>b<br>
<input type=radio name=rad value=c onclick=joe()>c<br>
<input type=radio name=rad value=d onclick=joe()>d<br>
<br>
You have selected <input type=text name=texti>
</form>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *