/* Основные стили */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
}
header {
background-color: #4CAF50;
color: white;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
}
.form-container {
padding: 20px;
max-width: 500px;
margin: 0 auto;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 8px;
font-weight: bold;
}
input {
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.result-container {
margin-top: 40px;
padding: 20px;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 500px;
margin: 0 auto;
}
#resultText {
font-size: 18px;
document.getElementById("birthForm").addEventListener("submit", function(event) {
event.preventDefault();
// Получение данных формы
const dob = document.getElementById("dob").value;
const place = document.getElementById("place").value;
if (!dob || !place) {
alert("Пожалуйста, заполните все поля.");
return;
}
// Преобразуем дату в числовые значения
const birthDate = new Date(dob);
const day = birthDate.getDate();
const month = birthDate.getMonth() + 1; // Месяцы начинаются с 0
const year = birthDate.getFullYear();
// Простой расчет (например, число жизненного пути)
const lifePathNumber = calculateLifePath(day, month, year);
// Вывод результата
const resultText = `Дата рождения: ${dob}
Место рождения: ${place}
Число жизненного пути: ${lifePathNumber}`;
document.getElementById("resultText").innerHTML = resultText;
});
// Функция для расчета числа жизненного пути
function calculateLifePath(day, month, year) {
const sum = day + month + year;
let lifePathNumber = sum;
// Суммируем цифры, пока не получим однозначное число
while (lifePathNumber > 9) {
lifePathNumber = lifePathNumber.toString().split('').reduce((acc, curr) => acc + parseInt(curr), 0);
}
return lifePathNumber;
}
}