function calculateZodiac() {
var yearInput = document.getElementById("birthYear").value;
var resultDiv = document.getElementById("zodiacResult");
var signName = document.getElementById("signName");
var signElement = document.getElementById("signElement");
var signPolarity = document.getElementById("signPolarity");
var signTraits = document.getElementById("signTraits");
var year = parseInt(yearInput);
if (isNaN(year) || year < 1) {
alert("Please enter a valid birth year.");
return;
}
var signs = [
{ name: "Monkey", traits: "Witty, intelligent, magnetic, and mischievous." },
{ name: "Rooster", traits: "Observant, hardworking, resourceful, and courageous." },
{ name: "Dog", traits: "Loyal, honest, amiable, and kind." },
{ name: "Pig", traits: "Compassionate, generous, diligent, and noble." },
{ name: "Rat", traits: "Quick-witted, resourceful, versatile, and kind." },
{ name: "Ox", traits: "Diligent, dependable, strong, and determined." },
{ name: "Tiger", traits: "Brave, confident, competitive, and charming." },
{ name: "Rabbit", traits: "Quiet, elegant, kind, and responsible." },
{ name: "Dragon", traits: "Confident, intelligent, enthusiastic, and powerful." },
{ name: "Snake", traits: "Enigmatic, intelligent, wise, and mysterious." },
{ name: "Horse", traits: "Animated, active, energetic, and optimistic." },
{ name: "Goat", traits: "Gentle, shy, stable, and sympathetic." }
];
var elements = ["Metal", "Metal", "Water", "Water", "Wood", "Wood", "Fire", "Fire", "Earth", "Earth"];
// Logic: Year modulo 12 determines the sign
var signIndex = year % 12;
var zodiac = signs[signIndex];
// Logic: Last digit of year determines the element
var lastDigit = year % 10;
var element = elements[lastDigit];
// Logic: Even years are Yang, Odd years are Yin
var polarity = (year % 2 === 0) ? "Yang (Positive)" : "Yin (Negative)";
signName.innerHTML = "You are a " + zodiac.name + "!";
signElement.innerHTML = element;
signPolarity.innerHTML = polarity;
signTraits.innerHTML = zodiac.traits;
resultDiv.style.display = "block";
}
Understanding the Chinese Zodiac System
The Chinese Zodiac, known as Shengxiao, is a repeating 12-year cycle based on the lunar calendar. Unlike the Western Zodiac which is based on constellations and months, the Chinese system assigns an animal and its reputed attributes to each year in the cycle.
The 12 Animal Signs
The order of the animals is based on an ancient legend called "The Great Race." The sequence is as follows: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, and Pig. Each animal has specific personality traits that are believed to be inherited by those born in that year.
The Five Elements (Wu Xing)
In addition to the animal signs, Chinese astrology incorporates five elements that further modify a person's character. These elements rotate every two years:
Wood: Symbolizes growth, creativity, and idealism.
Fire: Represents passion, dynamism, and leadership.
Earth: Denotes stability, reliability, and practicality.
Metal: Stands for focus, ambition, and determination.
Water: Represents flexibility, intuition, and diplomacy.
Yin and Yang
Years are also categorized by their polarity. Even-numbered years are considered Yang (active, masculine, outward-facing), while odd-numbered years are Yin (receptive, feminine, inward-facing).
Chinese Zodiac Calculation Examples
Birth Year
Animal Sign
Element
Polarity
1988
Dragon
Earth
Yang
1995
Pig
Wood
Yin
2000
Dragon
Metal
Yang
2012
Dragon
Water
Yang
Does the Lunar New Year Matter?
Yes. The Chinese Zodiac is based on the Lunar Calendar. If you were born in January or February, your sign might actually belong to the previous year. For example, if you were born on January 15th, 1990, you might still be a Snake instead of a Horse. This calculator provides the general year sign, but for high precision near the New Year transition, a full lunar calendar check is recommended.