|
在你的网站加上这样的有趣测试更具效果!
代码如下:(可自己设定标准的)
<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>
|
|
|
|