首页 新闻 会员 周边 捐助

谁可以帮我找一下错误啊,顺便翻译,急用啊,各位高手拜托了

0
悬赏园豆:100 [已解决问题] 解决于 2009-12-22 20:29

<html>
<head>
<title>检测健康程度</title>

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;

 function init () {
  if(ap_name=="Netscape" && ap_ver>=3.0)
  dl_ok=true;
  return true;
  }
 function get_time_spent () {
  var time_now = new Date();
  return((time_now.getTime() - clock_start)/1000);
  }
 function show_secs () {
  var i_total_secs = Math.round(get_time_spent());
  var i_secs_spent = i_total_secs % 60;
  var i_mins_spent = Math.round((i_total_secs-30)/60);
  var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);
  var s_mins_spent ="" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);
  document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;
  window.setTimeout('show_secs()',1000);
  }
// -->
</SCRIPT>

 

<style type="text/css">
<!--
body {  font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 4px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: none }
 A:hover { COLOR: red; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active     { font: 9pt "宋体"; cursor: hand; color: #FF0033 }
--></style>
</head>

<body onLoad="init(); window.setTimeout('show_secs()',1);">
<br>
<br>
<center>
<font color=red face="隶书" size=6>检测健康程度</font>
</center>

<br>
<center>
<table border=5 bordercolor=blue borderlight=green>

<tr><td align=center height=80>

<script LANGUAGE="JAVASCRIPT">


var imagenumber = 3 ;

var randomnumber = Math.random() ;

var rand = Math.round( (imagenumber-1) * randomnumber) + 1 ;

urls = new Array;

images = new Array;

alts = new Array;

var url = urls[rand];

var image = images[rand];

var alt = alts[rand];

function show(str)
{
 
  var o =document.getElementById(str);
  //o.style.display=(o.style.display=="none")?"":"none";
  o.style.display="";

}


function lookme(form) {

var bmi;
 
 if(! checkform(form))
return false;
 
 comput(form);
 
 bmi = Math.round(form.weight.value*10000/eval(form.height.value*form.height.value));
 
 document.getElementById('bmi').innerHTML= bmi;
 
 show("test_result");
 
 
  if (bmi >40) {
 
   document.getElementById('nowstat').innerHTML="啊,你还能买到衣服吗?\n你太、太...太胖了";
 
 }
else if (bmi >30) {
 
    document.getElementById('nowstat').innerHTML="哇!你好胖啊!必须开始减肥了,听我的没错";
 
 }
else if (bmi >27) {
 
    document.getElementById('nowstat').innerHTML="哎呀!你可是比较胖啊,赶快开始减肥计划吧!";
 
 }
else if (bmi >22) {
 
   document.getElementById('nowstat').innerHTML="小心喔!稍胖,少吃点可以吗?\n还要多多运动啊!:)";

  }
else if (bmi >=21) {
   
 document.getElementById('nowstat').innerHTML="我好羡慕你啊,你这可是魔鬼身材啊!! :))";
 
}
else if (bmi >=18) {
  
  document.getElementById('nowstat').innerHTML="瘦了一点点,你应该多吃点东西啊!";

  }
else if (bmi >=16) {
   
 document.getElementById('nowstat').innerHTML="你一定是受到了虐待,快点大量吃东西吧!";
 
}
else {
   
 document.getElementById('nowstat').innerHTML="哇塞!前胸贴后背,你怎么像个电线杆子\n一点肉都没有,快找大夫看看吧!!";
 
 }
 
 return true;

}

function comput(form) {
 
 if(form.sex.options.selectedIndex == "0")
 
  document.getElementById('legendweight').innerHTML = Math.round(50+(2.3*(form.height.value-152))/2.54);
 
 else
  
 document.getElementById('legendweight').innerHTML = Math.round(45.5+(2.3*(form.height.value-152))/2.54);

}


function ClearForm(form){

form.weight.value = "";

form.height.value = "";

document.getElementById('bmi').innerHTML = "";

document.getElementById('legendweight').innerHTML = "";

form.my_comment.value = "";

}

function bmi(weight, height) {

bmindx=weight/eval(height*height);
return bmindx;

}

 

function checkform(form){
  if(form.weight.value == null || form.weight.value.length ==0 ||
     form.height.value == null || form.height.value.length ==0) {
    alert("你以为我真的是神仙吗?你什么都不告诉我,我怎么给你测啊!!!");
 ClearForm(form);
    return false;
  }
  else if(form.weight.value <=0) {
    alert("你将创下体重最轻的吉尼斯世界记录,当心地心引力对你不起作用啊.");
 ClearForm(form);
    return false;
  }
  else if(form.weight.value >500) {
    alert("你不用测了,你的体重已经把我的秤压坏了.");
 ClearForm(form);
    return false;
  }
  else if(form.height.value <=0) {
    alert("你不至于这么矮吧,你怎么比蚂蚁还小呢?");
 ClearForm(form);
    return false;
  }
  else if(form.height.value >=300) {
    alert("喔!!!!你好伟大啊!!!!\n替我向上帝问好");
 ClearForm(form);
    return false;
  }
  return true;
}
</script>


<form NAME="BMI" method="POST">

  <table border="1" align="center" cellspacing="1">
  <tr>
  <td>
  <table border="1" align="center" cellspacing="1">
    <tr>
      <td width="105"><div align="center"><font color="red">性别</font></div></td>
      <td width="130"><div align="center"><font color="red">体重</font> (kg)</div></td>
      <td width="192" align="center"><div align="center"><font color="red">身高</font>(cm)</div></td>
      <td width="111" align="center"><div align="center"><font color="blue">健康值</font></div></td>
     
    </tr>
    <tr align="center">
      <td>
 <Select size=1 name=***>
   <Option value=0 selected>男</Option>
   <Option value=1>女</Option>
 </Select>
      </td>
      <td><input TYPE="TEXT" NAME="weight" SIZE="6" onFocus="this.form.weight.value=''"></td>
      <td><input TYPE="TEXT" NAME="height" SIZE="6" onFocus="this.form.height.value=''"></td>
      <td><input TYPE="TEXT" NAME="bmi" SIZE="5"></td>
    
    </tr>
    </table>
    </td>
    </tr>
  
   <tr>
   <td>
   <table border="1" cellspacing="1">
     <tr>
     <td width="190" align="center"><font color="blue">您的理想体重(cm)</font></td>
    <td width="356" align="center"><font color="blue">电脑对您的评价</font></td>
    </tr>
     <tr>
     <td align="center" valign="middle"><INPUT TYPE="TEXT" onfocus=blur() size=6 name="legendweight"></td>
      <td align="center" valign="middle"><input TYPE="TEXT" NAME="my_comment" size="40"></td>
    </tr>
    </table>
    </td>
    </tr>
  </table>

  <div align="center">
  <center>
  <p>
  <INPUT onClick="lookme(this.form)" type="button" value="开始测试">
  <INPUT type="reset" value="重新填写" >
 
   </p>
  </center>
  </div>
</form>
</td>
</tr>

<tr>
<td>
<form name="fm0" onSubmit="0">
<center>
<font size="-1" COLOR="#888888"><I>您在本网页的停留时间:</I></font><br>
<INPUT type="text" name="time_spent" size=7 onFocus="this.blur()">
</center>
</form>
</td>
</tr>
</table>
</center>

 


</body>
</html>

381201682的主页 381201682 | 初学一级 | 园豆:99
提问于:2009-12-19 13:50
< >
分享
最佳答案
0

 

 下面这段在IE下面运行测试通过:

 主要是

document.getElementById("");
document.getElementsByName(""); 没有区分好。

 还有就是 innerHTML 和 value;
<html>
<head>
    <title>检测健康程度</title>

    <script language="JAVASCRIPT">
<!--
var ap_name = navigator.appName;
var ap_vinfo = navigator.appVersion;
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));
var time_start = new Date();
var clock_start = time_start.getTime();
var dl_ok=false;

 function init () {
  if(ap_name=="Netscape" && ap_ver>=3.0)
  dl_ok=true;
  return true;
  }
 function get_time_spent () {
  var time_now = new Date();
  return((time_now.getTime() - clock_start)/1000);
  }
 function show_secs () {
  var i_total_secs = Math.round(get_time_spent());
  var i_secs_spent = i_total_secs % 60;
  var i_mins_spent = Math.round((i_total_secs-30)/60);
  var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);
  var s_mins_spent ="" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);
  document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;
  window.setTimeout('show_secs()',1000);
  }
// -->
    </script>

    <style type="text/css">
<!--
body {  font-family: "宋体"; font-size: 9pt; margin-top: 0px; margin-left: 4px; margin-right: 0px}
A { COLOR: black; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: none }
 A:hover { COLOR: red; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: underline }
a:active     { font: 9pt "宋体"; cursor: hand; color: #FF0033 }
--></style>
</head>
<body onload="init(); window.setTimeout('show_secs()',1);">
    <br>
    <br>
    <center>
        <font color="red" face="隶书" size="6">检测健康程度</font>
    </center>
    <br>
    <center>
        <table border="5" bordercolor="blue" borderlight="green">
            <tr>
                <td align="center" height="80">

                    <script language="JAVASCRIPT">


var imagenumber = 3 ;

var randomnumber = Math.random() ;

var rand = Math.round( (imagenumber-1) * randomnumber) + 1 ;

urls = new Array;

images = new Array;

alts = new Array;

var url = urls[rand];

var image = images[rand];

var alt = alts[rand];

function show(str)
{
 
  var o =document.getElementById(str);
  //o.style.display=(o.style.display=="none")?"":"none";
  o.style.display="";

}


function lookme(form) {

var bmi;
 
 if(! checkform(form))
return false;
 
 comput(form);
 
 bmi = Math.round(form.weight.value*10000/eval(form.height.value*form.height.value));
 
 document.getElementById('bmi').value= bmi;
 
 //show("test_result");
 
 
  if (bmi >40) {
 
   document.getElementById('my_comment').value="啊,你还能买到衣服吗?\n你太、太...太胖了";
 
 }
else if (bmi >30) {
 
    document.getElementById('my_comment').value="哇!你好胖啊!必须开始减肥了,听我的没错";
 
 }
else if (bmi >27) {
 
    document.getElementById('my_comment').value="哎呀!你可是比较胖啊,赶快开始减肥计划吧!";
 
 }
else if (bmi >22) {
 
   document.getElementById('my_comment').value="小心喔!稍胖,少吃点可以吗?\n还要多多运动啊!:)";

  }
else if (bmi >=21) {
   
 document.getElementById('my_comment').value="我好羡慕你啊,你这可是魔鬼身材啊!! :))";
 
}
else if (bmi >=18) {
  
  document.getElementById('my_comment').value="瘦了一点点,你应该多吃点东西啊!";

  }
else if (bmi >=16) {
   
 document.getElementById('my_comment').value="你一定是受到了虐待,快点大量吃东西吧!";
 
}
else {
   
 document.getElementById('my_comment').value="哇塞!前胸贴后背,你怎么像个电线杆子\n一点肉都没有,快找大夫看看吧!!";
 
 }
 
 return true;

}

function comput(form) {
 
 if(form.sex.options.selectedIndex == "0")
 
  document.getElementById('legendweight').value = Math.round(50+(2.3*(form.height.value-152))/2.54);
 
 else
  
 document.getElementById('legendweight').value = Math.round(45.5+(2.3*(form.height.value-152))/2.54);

}


function ClearForm(form){

form.weight.value = "";

form.height.value = "";

document.getElementById('bmi').value = "";

document.getElementById('legendweight').value = "";

form.my_comment.value = "";

}

function bmi(weight, height) {

bmindx=weight/eval(height*height);
return bmindx;

}

 

function checkform(form){
  if(form.weight.value == null || form.weight.value.length ==0 ||
     form.height.value == null || form.height.value.length ==0) {
    ;
 ClearForm(form);
    return false;
  }
  else if(form.weight.value <=0) {
    ;
 ClearForm(form);
    return false;
  }
  else if(form.weight.value >500) {
    ;
 ClearForm(form);
    return false;
  }
  else if(form.height.value <=0) {
    ;
 ClearForm(form);
    return false;
  }
  else if(form.height.value >=300) {
    ;
 ClearForm(form);
    return false;
  }
  return true;
}
                    </script>

                    <form name="BMI" method="POST">
                        <table border="1" align="center" cellspacing="1">
                            <tr>
                                <td>
                                    <table border="1" align="center" cellspacing="1">
                                        <tr>
                                            <td width="105">
                                                <div align="center">
                                                    <font color="red">性别</font></div>
                                            </td>
                                            <td width="130">
                                                <div align="center">
                                                    <font color="red">体重</font> (kg)</div>
                                            </td>
                                            <td width="192" align="center">
                                                <div align="center">
                                                    <font color="red">身高</font>(cm)</div>
                                            </td>
                                            <td width="111" align="center">
                                                <div align="center">
                                                    <font color="blue">健康值</font></div>
                                            </td>
                                        </tr>
                                        <tr align="center">
                                            <td>
                                                <select size="1" name="sex" id="sex">
                                                    <option value="0" selected>男</option>
                                                    <option value="1">女</option>
                                                </select>
                                            </td>
                                            <td>
                                                <input type="TEXT" name="weight" size="6" onfocus="this.form.weight.value=''"></td>
                                            <td>
                                                <input type="TEXT" name="height" size="6" onfocus="this.form.height.value=''"></td>
                                            <td>
                                                <input type="TEXT" name="bmi" size="5" id="bmi"></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table border="1" cellspacing="1">
                                        <tr>
                                            <td width="190" align="center">
                                                <font color="blue">您的理想体重(kg)</font></td>
                                            <td width="356" align="center">
                                                <font color="blue">电脑对您的评价</font></td>
                                        </tr>
                                        <tr>
                                            <td align="center" valign="middle">
                                                <input type="TEXT" onfocus="blur()" size="6" name="legendweight" id='legendweight'></td>
                                            <td align="center" valign="middle">
                                                <input type="TEXT" name="my_comment" id='my_comment' size="40" /></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <div align="center">
                            <center>
                                <p>
                                    <input onclick="lookme(this.form)" type="button" value="开始测试">
                                    <input type="reset" value="重新填写">
                                </p>
                            </center>
                        </div>
                    </form>
                </td>
            </tr>
            <tr>
                <td>
                    <form name="fm0" onsubmit="0">
                        <center>
                            <font size="-1" color="#888888"><i>您在本网页的停留时间:</i></font><br>
                            <input type="text" name="time_spent" size="7" onfocus="this.blur()">
                        </center>
                    </form>
                </td>
            </tr>
        </table>
    </center>
</body>
</html>

收获园豆:100
woody.wu | 老鸟四级 |园豆:3621 | 2009-12-19 21:52
其他回答(1)
0

呵呵,这个问题你要不能自己解决,你就不要写代码了。

基本概念:

1、getElementById(“nowstat”);//查找当前form的ID为“nowstat”的页面控件,你页面的定义全是name,有没有定义ID="nowstat'啊?

2、一般div用innerHTML,input对应的是value,你查一下页面的div

邀月 | 园豆:25475 (高人七级) | 2009-12-19 16:17
又不是我想写的,这也是百度来的,不是我写的
支持(0) 反对(0) 381201682 | 园豆:99 (初学一级) | 2009-12-19 18:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册