js实现根据年份获取生肖

js实现根据年份获取生肖,js输入年份输出生肖的代码教程如下:

输入一个出生年份

实现结果:计算出生年份对应的生肖

js实现代码如下:


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;
}

显示效果:十二生肖查询

参考文章:http://www.itmacom.com/gl/33485.html

1000个脑筋急转弯

猜字谜语大全

年利率计算器

面积单位换算

方差计算器

排列组合计算器

posted @ 2023-06-01 14:47  kaiser099  阅读(172)  评论(0编辑  收藏  举报