1.生日算年龄
<SCRIPT LANGUAGE="JavaScript">
<!--
function getAge(birth){//参数为出生年月,如1980/5/9
  var now=new Date();
  var old=new Date(birth);
  //alert(now)
  alert(" 此人年龄为"+(now.getFullYear()-old.getFullYear())+"岁");
  alert("天数为"+Math.round(Math.abs(old.getTime()-now.getTime())/(24*60*60*1000))+"天");
}
//-->
</SCRIPT>

解决方案 »

  1.   

    2.2、利用单选项控制两个文本框是否可编辑(你用这个参考一下)
    <html>
    <head>
    <script language=JavaScript>
    function eyun(v)
      {if(v==2)
         dia_pass.style.display="";
       else
         dia_pass.style.display="none";
      }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>  <table width="500" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td height="56" colspan="3">&nbsp; 
          <p>
            <select onchange="eyun(this.value)">
              <option value=1>无</option>
              <option value=2>有</option>
            </select>
          </p>
          
            <input name="dia_pass" type="password" style="display:none">
      
         </td>
      </tr>
    </table>
    </body>
    </html>
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <p>
      
      
      <input type="radio" name="rb1" value="1" onClick="change()">
      Y<input type="text" name="text1" readonly="true">
      <input type="radio" name="rb1" value="2" onClick="change()"> 
      N<input type="text" name="text2"readonly="true">
      
    </p></body>
    </html>
    <script language="javascript1.1">
    function change(){
    var radios = document.all("rb1");
    if(radios[0].checked){
    document.all("text1").readOnly = false;
    document.all("text2").readOnly = true;
    }
    if(radios[1].checked){
    document.all("text1").readOnly = true;
    document.all("text2").readOnly = false;
    }
    }</script>