·设为首页
·联系站长
·加入收藏
 您的位置: 【网络时空】 豪发网络 >> 文章教程 >> 综合网页文章 >> 正文
  趣味健康测试代码    3星级
趣味健康测试代码
[ 作者:佚名     转贴自:来自网络     点击数:     更新时间:2005-11-3     文章录入:aken
【字体: 字体颜色      双击自动滚屏

在你的网站加上这样的有趣测试更具效果!

代码如下:(可自己设定标准的)

<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
  <td width="150" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr align="center" bgcolor="#99CC66">
      <td class="biaoti02" height="20" valign="bottom" align="center" bgcolor="#99CC66">趣
        味 健 康 测 试</td>
    </tr>
    <tr>
      <td bgcolor="#000000"></td>
    </tr>
    <tr>
      <td>
        <script LANGUAGE="JAVASCRIPT">
<!-- hide this script tag's contents from old browsers
function ClearForm(form){
form.weight.value = "";
form.height.value = "";
form.bmi.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){
alert("\nPlease complete the form first");
return false;}
else if (parseFloat(form.height.value) <= 0││
parseFloat(form.height.value) >=500││
parseFloat(form.weight.value) <= 0││
parseFloat(form.weight.value) >=500){
alert("\nReally know what you're doing? \nPlease enter values again. \nWeight in kilos and \nheight in cm");
ClearForm(form);
return false;}
return true;}
function computeform(form) {
if (checkform(form)) {
yourbmi=Math.round(bmi(form.weight.value, form.height.value/100));
form.bmi.value=yourbmi;
if (yourbmi >30) {
form.my_comment.value="不要再闹了!!!";}
else if (yourbmi >28 && yourbmi <=30) {
form.my_comment.value="您是猪吗?";}
else if (yourbmi >23 && yourbmi <=28) {
form.my_comment.value="两头猪也没有你重吧?";}
else if (yourbmi >21 && yourbmi <=23) {
form.my_comment.value="您现在是偏胖,应该注意饮食!";}
else if (yourbmi >=19 && yourbmi <=21) {
form.my_comment.value="哇!!!您太苗条了! 是标准身材";}
else if (yourbmi >=18 && yourbmi <19) {
form.my_comment.value="您是不是营养不良?????";}
else if (yourbmi >=17 && yourbmi <18) {
form.my_comment.value="这个不是骨头吗????";}
else if (yourbmi <17) {
form.my_comment.value="按照生物学来说这种生物是不能生存的";}}
return;}
// -- done hiding from old browsers -->
</script>
        <form NAME="BMI" method="POST">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#CCCCFF">
          <tr>
            <td width="50%" align="center"><font color="red"><span class="a1">体重</span></font><span class="a1">
            (kg)</span></td>
            <td rowspan="5" width="1" bgcolor="#FFFFFF"></td>
            <td rowspan="2">
            <input type="TEXT" name="weight" size="9" onFocus="this.form.weight.value=''">
            </td>
          </tr>
          <tr>
            <td width="50%" height="1" bgcolor="#000000"></td>
          </tr>
          <tr>
            <td width="50%" align="center"><font color="red"><span class="a1">身高</span></font><span class="a1">
            (cm)</span></td>
            <td rowspan="2">
            <input type="TEXT" name="height" size="9" onFocus="this.form.height.value=''">
            </td>
          </tr>
          <tr>
            <td width="50%" height="1" bgcolor="#000000"></td>
          </tr>
          <tr>
            <td align="center"><font color="blue"><span class="a1">健 康 值</span></font></td>
            <td>
            <input type="TEXT" name="bmi" size="9">
            </td>
          </tr>
          <tr>
            <td colspan="3" height="1" bgcolor="#000000"></td>
          </tr>
          <tr>
            <td colspan="3" align="center"><font color="blue" class="a1">电脑对您的评价</font></td>
          </tr>
          <tr>
            <td colspan="3" align="center">
            <textarea name="my_comment" cols="18"></textarea>
            </td>
          </tr>
          <tr>
            <td colspan="3" align="center">
            <input type="button" value="确定"onClick="computeform(this.form)" name="button">
              
            <input type="reset" value="取消"onClick="ClearForm(this.form)" name="reset">
            </td>
          </tr>
        </table>
        </form>
      </td>
    </tr>
    </table>
 
  • 上一篇文章: 网页代码常用小技巧!

  • 下一篇文章: 在主页中制作连续的背景音乐
  • 发表评论   告诉好友   打印此文  关闭窗口
     最新5篇热点文章
    网页简繁转换功能[495]
    特殊字符总汇[453]
    通过CSS实现按钮图片效果[737]
    CSS特效赏析[851]
    HTML语法效果[856]
     
     最新5篇推荐文章
    如何制作透明FLASH[02-03]
    非常全的主页设置代码[12-29]
    个性网页鼠标(游标)攻略[12-25]
    透明flash代码[11-03]
    网页代码常用小技巧![10-31]
     
     相 关 文 章

      网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!)