<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js Get an instance of radio button value</title>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="RadioGroup1" value="Single choice" />
Single choice</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Single choice" />
Single choice</label>
<br />
<label>
<input name="RadioGroup1" type="radio" value="Single choice" />
Single choice</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Single choice" />
Single choice</label>
<input type="submit" name="button" value="submit" onclick="javascript:return checksubmit()" />
<br />
</p>
</form>
<script>
function checksubmit()
{
if( GetRadioValue('RadioGroup1') )
{
alert('s optional');
}
else
{
alert('Not selected');
}
}
function GetRadioValue(RadioName){
var obj;
obj=(RadioName);
if(obj!=null){
var i;
for(i=0;i<;i++){
if(obj[i].checked){
return obj[i].value;
}
}
}
return null;
}
</script>
</body>
</html>