Saber 酱的抱枕

Fly me to the moon

10/8
2014
学习

身高测试js

网站需要,从别的网站扒下来改造的娱乐而已,别当真

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
	<script type="text/javascript"> 
	  function coHeight(){
			if(document.all.sex[0].checked==true){
				var mySex = "m";
			}
			else if(document.all.sex[1].checked==true){
				var mySex = "f";
			}
			else{
				alert('请选择您的性别!');
				document.all.sex.focus();
				return;
			}
			if(document.all.fh.value.length>0){
				var myFH=parseInt(document.all.fh.value);
			}else{
				alert('请填写您父亲的身高!');
				document.all.fh.focus();
				return;
			}
			if(document.all.mh.value.length>0){
				var myMH=parseInt(document.all.mh.value);
			}else{
				alert('请填写您母亲的身高!');
				document.all.mh.focus();
				return;
			}
			if(mySex=="m"){
				var myH = ((myFH+myMH)+13)/2+6;
			}
			if(mySex=="f"){
				var myH = ((myFH+myMH)-13)/2+6;
			}
			alert('根据遗传基因数推算,你成年身高为:'+myH+'CM');
		}
	</script> 
  <table width="220" border="0" style="font-size:14px;"> 
   <tbody>
    <tr style="height:30px;"> 
     <td width="40%">您父亲的身高</td> 
     <td width="60%" style="padding-left:10px;"><input class="kuang" type="text" name="fh" style="width:100px;" id="textfield" /></td> 
    </tr> 
    <tr style="height:30px;"> 
     <td>您母亲的身高</td> 
     <td style="padding-left:10px;"><input class="kuang" type="text" name="mh" style="width:100px;" id="textfield2" /></td> 
    </tr> 
    <tr style="height:30px;"> 
     <td align="center"><label> <input type="radio" name="sex" checked="checked" value="单选" id="RadioGroup1_0" /> 男</label> </td> 
     <td style="padding-left:20px;"><label> <input type="radio" name="sex" value="单选" id="RadioGroup1_1" /> 女</label> </td> 
    </tr> 
    <tr style="height:30px;"> 
     <td colspan="2" style="padding-left:60px;"> <button value="测试" style="border:1px solid #ccc; background:#eee; border-radius:2px; text-align:center; width:70px; height:26px; line-height:26px; cursor:pointer;" onclick="coHeight();">测 试</button> </td> 
    </tr> 
   </tbody>
  </table>
</body>
</html>

身高测试js