Javascripts > Misc Javascripts > Chinese Zodiac
Script Title: Chinese Zodiac
Description: A fun JavaScript that tells you your Chinese Zodiac sign! Just enter your birth year, and see what corresponding animal you are!
Example: Available
Enter your birth year. For example: "1975"
Copy the following code into your <HEAD></HEAD> tags.<script LANGUAGE="JavaScript"> <!-- /* For this script, visit http://java-scripts.net or http://wsabstract.com */ function getpet () { var toyear = 1997; var birthyear = document.frm.inyear.value; var birthpet="Ox" x = (toyear - birthyear) % 12 if ((x == 1) || (x == -11)) { birthpet="Mouse" } else { if (x == 0) { birthpet="Ox" } else { if ((x == 11) || (x == -1)) { birthpet="Tiger" } else { if ((x == 10) || (x == -2)) { birthpet="Rabbit" } else { if ((x == 9) || (x == -3)) { birthpet="Dragon" } else { if ((x == 8) || (x == -4)) { birthpet="Snake" } else { if ((x == 7) || (x == -5)) { birthpet="Horse" } else { if ((x == 6) || (x == -6)) { birthpet="Sheep" } else { if ((x == 5) || (x == -7)) { birthpet="Monkey" } else { if ((x == 4) || (x == -8)) { birthpet="Chicken" } else { if ((x == 3) || (x == -9)) { birthpet="Dog" } else { if ((x == 2) || (x == -10)) { birthpet="Pig" } } } } } } } } } } } } document.frm.birth.value = birthpet; } // --> </script>
Copy the following code between the <BODY></BODY> tags of your html page.<p>Enter your birth year. For example: "1975" <form NAME="frm"> <input TYPE="text" SIZE="4" NAME="inyear" value="1975"> <input TYPE="button" VALUE="My pet, please" onClick="getpet()"><br> <p><input TYPE="text" SIZE="9" NAME="birth"> </form>
Enter your name and email address to have this script sent right to your Inbox for later viewing. First Name Last Name Email