<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js操作单选按钮跟复选框</title>
<script language="javascript" type="text/javascript">
 function show(){
  var sex;
  if(document.myform.sex[0].
checked){
   sex=document.myform.sex[0].value;
  }else{
   sex=document.myform.sex[1].value;
  }
  alert("性别:"+sex);  
  var interest="";
  for(i=0;i<document.myform.inst.length;i++){
   if(document.myform.inst[i].checked){
    interest+=document.myform.inst[i].value+"---";
    }
   }
   alert("兴趣:"+interest);
 }
</script>
</head>
<body>
 <form action="" method="post" name="myform">
    性别:<input type="radio" name="sex" value="男" checked="checked" />男
    <input type="radio" name="sex" value="女"  />女<br />   
    兴趣:<input type="
checkbox" name="inst" value="sing" />唱歌
    <input type="checkbox" name="inst" value="dance" />跳舞
    <input type="checkbox" name="inst" value="read" />阅读
    <input type="checkbox" name="inst" value="sleep" />睡觉<br />
    <input type="button" value="显示" onclick="show()" />
    </form> 
</body>
</html>