document.addEventListener('DOMContentLoaded', function() {
let currentStep = 1;
function updateSteps() {
document.querySelectorAll('.step-content').forEach((step, index) => {
step.classList.toggle('active', index === currentStep - 1);
});
document.querySelectorAll('.progress-step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
const form = document.querySelector('.multi-step-form');
form.classList.toggle('first-step', currentStep === 1);
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
updateSteps();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateSteps();
}
}
updateSteps();
document.querySelectorAll('.option-card[data-step="1"]').forEach(card => {
card.addEventListener('click', function() {
document.querySelectorAll('.option-card[data-step="1"]').forEach(c => c.classList.remove('active'));
this.classList.add('active');
setTimeout(() => nextStep(), 200);
});
});
});
document.addEventListener('DOMContentLoaded', function() {
let currentStep = 1;
function showStep(step) {
document.querySelectorAll('.step-content').forEach(content => {
content.classList.remove('active');
});
document.querySelector(`.step-content.step-${step}`).classList.add('active');
document.querySelectorAll('.progress-step').forEach(stepEl => {
stepEl.classList.remove('active');
});
for (let i = 1; i <= step; i++) {
document.querySelector(`.progress-step.step-${i}`).classList.add('active');
}
document.querySelector('.multi-step-form').classList.toggle('first-step', step === 1);
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
showStep(currentStep);
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
showStep(currentStep);
}
}
// Клик по карточкам (Step 1)
document.querySelectorAll('.option-card').forEach(card => {
card.addEventListener('click', nextStep);
});
// Слушаем радиокнопки для Step 2-4
document.querySelectorAll('input[type="radio"]').forEach(radio => {
radio.addEventListener('change', nextStep);
});
// Назад — сделать доступным глобально
window.prevStep = prevStep;
// Показать первый шаг при загрузке
showStep(currentStep);
});
window.addEventListener('load', function() {
let currentStep = 1;
function updateSteps() {
document.querySelectorAll('.step-content').forEach((step, index) => {
step.classList.toggle('active', index === currentStep - 1);
});
document.querySelectorAll('.progress-step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
document.querySelector('.multi-step-form')?.classList.toggle('first-step', currentStep === 1);
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
updateSteps();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateSteps();
}
}
document.querySelector('.back-btn')?.addEventListener('click', prevStep);
document.querySelectorAll('.option-card[data-step="1"]').forEach(card => {
card.addEventListener('click', function() {
document.querySelectorAll('.option-card[data-step="1"]').forEach(c => c.classList.remove('active'));
this.classList.add('active');
nextStep();
});
});
document.querySelectorAll('.option input[type="radio"]').forEach(radio => {
radio.addEventListener('change', nextStep);
});
updateSteps();
});
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('.multi-step-1form');
if (!form) return;
let currentStep = 1;
function updateSteps() {
form.querySelectorAll('.step-content').forEach((step, index) => {
step.classList.toggle('active', index === currentStep - 1);
});
form.querySelectorAll('.progress-step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
form.classList.toggle('first-step', currentStep === 1);
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
updateSteps();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateSteps();
}
}
const backBtn = form.querySelector('.back-btn');
if (backBtn) {
backBtn.addEventListener('click', prevStep);
}
// Выбор карточки на 1 шаге
form.querySelectorAll('.option-card[data-step="1"]').forEach(card => {
card.addEventListener('click', function() {
form.querySelectorAll('.option-card[data-step="1"]').forEach(c => c.classList.remove('active'));
this.classList.add('active');
nextStep();
});
});
// Выбор radio кнопок на следующих шагах
form.querySelectorAll('.option input[type="radio"]').forEach(radio => {
radio.addEventListener('change', nextStep);
});
updateSteps();
});
document.addEventListener('DOMContentLoaded', function() {
let currentStep = 1;
function updateSteps() {
document.querySelectorAll('.step-content').forEach((step, index) => {
step.classList.toggle('active', index === currentStep - 1);
});
document.querySelectorAll('.progress-step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
const form = document.querySelector('.multi-step-form');
if (currentStep === 1) {
form.classList.add('first-step');
} else {
form.classList.remove('first-step');
}
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
updateSteps();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateSteps();
}
}
updateSteps();
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('.multi-step-form');
if (!form) return;
let currentStep = 1;
function updateSteps() {
document.querySelectorAll('.step-content').forEach((step, index) => {
step.classList.toggle('active', index === currentStep - 1);
});
document.querySelectorAll('.progress-step').forEach((step, index) => {
step.classList.toggle('active', index < currentStep);
});
const form = document.querySelector('.multi-step-form');
if (currentStep === 1) {
form.classList.add('first-step');
} else {
form.classList.remove('first-step');
}
}
function nextStep() {
if (currentStep < 5) {
currentStep++;
updateSteps();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateSteps();
}
}
updateSteps();
Comments are closed