根据出生日期自动取得星座的js代码

2019-12-24,,,

无奈啊~只怪读书时没有好好用功~看着JavaScript,一个头顿时变成两个。。。。。。。。
还好网络提供了很好的资料库~看了下,然后自己改了下,基本算能完成任务吧~写下一份存档,留待日后
复制代码 代码如下:
function xingzuo() {
var start = 1901, date=document.getElementById("txtDay").value, month=document.getElementById("txtMonth").value;;
with (document.getElementById("txtXZ")){
if (month == 1 && date >=20 || month == 2 && date <=18) {value = "水瓶座";}
if (month == 1 && date > 31) {value = "Huh?";}
if (month == 2 && date >=19 || month == 3 && date <=20) {value = "双鱼座";}
if (month == 2 && date > 29) {value = "Say what?";}
if (month == 3 && date >=21 || month == 4 && date <=19) {value = "白羊座";}
if (month == 3 && date > 31) {value = "OK. Whatever.";}
if (month == 4 && date >=20 || month == 5 && date <=20) {value = "金牛座";}
if (month == 4 && date > 30) {value = "I'm soooo sorry!";}
if (month == 5 && date >=21 || month == 6 && date <=21) {value = "双子座";}
if (month == 5 && date > 31) {value = "Umm ... no.";}
if (month == 6 && date >=22 || month == 7 && date <=22) {value = "巨蟹座";}
if (month == 6 && date > 30) {value = "Sorry.";}
if (month == 7 && date >=23 || month == 8 && date <=22) {value = "狮子座";}
if (month == 7 && date > 31) {value = "Excuse me?";}
if (month == 8 && date >=23 || month == 9 && date <=22) {value = "室女座";}
if (month == 8 && date > 31) {value = "Yeah. Right.";}
if (month == 9 && date >=23 || month == 10 && date <=22) {value = "天秤座";}
if (month == 9 && date > 30) {value = "Try Again.";}
if (month == 10 && date >=23 || month == 11 && date <=21) {value = "天蝎座";}
if (month == 10 && date > 31) {value = "Forget it!";}
if (month == 11 && date >=22 || month == 12 && date <=21) {value = "人马座";}
if (month == 11 && date > 30) {value = "Invalid Date";}
if (month == 12 && date >=22 || month == 1 && date <=19) {value = "摩羯座";}
if (month == 12 && date > 31) {value = "No way!";}
}
}

您可能感兴趣的文章:

  • js中 计算两个日期间的工作日的简单实例
  • js计算系统当前日期是星期几的方法
  • javascript日期计算实例分析
  • JavaScript计算两个日期时间段内日期的方法
  • javaScript 计算两个日期的天数相差(示例代码)
  • js根据给定的日期计算当月有多少天实现思路及代码
  • 一个简单的JavaScript 日期计算算法
  • 用javascript实现计算两个日期的间隔天数
  • js根据日期判断星座的示例代码
  • javascript计算星座属相(十二生肖属相)示例代码
  • JS根据生日月份和日期计算星座的简单实现方法

《根据出生日期自动取得星座的js代码.doc》

下载本文的Word格式文档,以方便收藏与打印。