首页 > web前端 > js教程 > 正文

用js实现的生肖查询的代码

PHP中文网
发布: 2016-05-16 18:10:04
原创
1601 人浏览过

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>生肖查询</title> 
<style type="text/css"> 
<!-- 
td,body {font-size:12px} 
a:link {color:#000000;text-decoration:none} 
a:visited {color:#000000;text-decoration:none} 
a:active {color:blue;text-decoration:none} 
a:hover {color:red;text-decoration:underline} 
a.title:link {color:#000000;text-decoration:underline} 
a.title:visited {color:#000000;text-decoration:underline} 
a.title:active {color:#0000ff;text-decoration:underline} 
a.title:hover {color:#0000ff;text-decoration:underline} 
--> 
</style> 
<SCRIPT language=JavaScript> 
<!-- 
function getpet () { 
var toyear = 1997; 
var birthyear = document.frm.inyear.value; 
var birthpet="Ox" 
x = (toyear - birthyear) % 12 
if ((x == 1) || (x == -11)) { 
birthpet="鼠" } 
else { 
if (x == 0) { 
birthpet="牛" } 
else { 
if ((x == 11) || (x == -1)) { 
birthpet="虎" } 
else { 
if ((x == 10) || (x == -2)) { 
birthpet="兔" } 
else { 
if ((x == 9) || (x == -3)) { 
birthpet="龙" } 
else { 
if ((x == 8) || (x == -4)) { 
birthpet="蛇" } 
else { 
if ((x == 7) || (x == -5)) { 
birthpet="马" } 
else { 
if ((x == 6) || (x == -6)) { 
birthpet="羊" } 
else { 
if ((x == 5) || (x == -7)) { 
birthpet="猴" } 
else { 
if ((x == 4) || (x == -8)) { 
birthpet="鸡" } 
else { 
if ((x == 3) || (x == -9)) { 
birthpet="狗" } 
else { 
if ((x == 2) || (x == -10)) { 
birthpet="猪" } 
} 
} 
} 
} 
} 
} 
} 
} 
} 
} 
} 
document.frm.birth.value = birthpet; 
} 
// --> 
</SCRIPT> 
</head> 
<table width="760" height="22" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#aaaaaa" bordercolordark="#ffffff"> 
<tbody> 
<tr> 
<td height="20" align="center"><table width="100%" border="0"> 
<tr> 
<td width="54%"><b><font color="#424242"><strong><font color="#424242">目前位置>><a href="/" target="_self">首页</a>></font></strong></font><a href="/tools" target="_self">实用查询</a>>生肖查询</b></td> 
<td width="46%"> </td> 
</tr> 
</table></td> 
</tr> 
</tbody> 
</table> 
<table width="760" border="0" align="center" cellspacing="0"> 
<tr> 
<td width="760" height="10"></td> 
</tr> 
</table> 
<DIV align=center><span class="style2"> 
生肖查询</span></div> 
<P align=center> 
<FORM name=frm> 
<div align="center">生于:   
<INPUT size=4 value=1986 name=inyear> 
  年   
<INPUT onclick=getpet() type=button value=查看生肖> 
   属:  
<INPUT size=3 
name=birth> 
</div> 
</FORM><TR> 
<TD width="100%" height="6" align="center" bgcolor="#FFFFFF"><FONT color=#ff0000>  </TD> 
</TR> 
<TR> 
<TD 
align="center" height="5" width="100%"> </TD> 
</TR></P> 
<div align="center"><span class="style1">当然没有人回忘记自己属什么。。但是你可以很轻松得知道任何年份出世得人的属相。。填入查询出生在哪一年,例如:"1986"</span> 
</div> 
<p> </p> 
</body> 
</html>
登录后复制


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!