/
Coderdev
/
web-nodejs-labs
Обзор
Документация
Войти
/
Coderdev
/
web-nodejs-labs
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
public/lab7/task2/index.html
65 строк
3 KB
Coderdev
1
12 май 2026, 12:34
12 май 2026, 12:34
f5e899f
Код
Авторство
О чём код?
<!DOCTYPE html> <html> <head> <title>Задание 2: Анкета</title> <meta charset="utf-8"> </head> <body> <h1>Анкета пользователя</h1> <form id="userForm"> <input type="text" id="lastname" placeholder="Фамилия" required><br><br> <input type="text" id="firstname" placeholder="Имя" required><br><br> <input type="text" id="surname" placeholder="Отчество"><br><br> <label>Пол:</label> <input type="radio" name="gender" value="m"> М <input type="radio" name="gender" value="f"> Ж <br><br> <label>Факультет:</label> <select id="faculty"> <option value="it">ИТ</option> <option value="design">Дизайн</option> <option value="econ">Экономика</option> </select><br><br> <label> <input type="checkbox" id="participation" onchange="toggleProject()"> Участие в проекте </label><br><br> <div id="projectBlock" style="display:none;"> <input type="text" id="projectName" placeholder="Название проекта"> </div><br> <button type="button" onclick="saveData()">Сохранить</button> </form> <div id="output" style="margin-top: 20px; border-top: 1px solid #ccc;"></div> <script> function toggleProject() { const checkbox = document.getElementById('participation'); document.getElementById('projectBlock').style.display = checkbox.checked ? 'block' : 'none'; } async function saveData() { const lastname = document.getElementById('lastname').value; const firstname = document.getElementById('firstname').value; const surname = document.getElementById('surname').value; const participation = document.getElementById('participation').checked; // Вызываем оба эндпоинта для демонстрации const resInitials = await fetch(`/api/lab7/task2/makeInitials?lastname=${lastname}&firstname=${firstname}&surname=${surname}`); const dataInitials = await resInitials.json(); const resStatus = await fetch(`/api/lab7/task2/makeProjectStatus?lastname=${lastname}&firstname=${firstname}&surname=${surname}&participation=${participation}`); const dataStatus = await resStatus.json(); document.getElementById('output').innerHTML = ` <p>Инициалы: ${dataInitials.lastname} ${dataInitials.firstnameLetter}${dataInitials.surnameLetter}</p> <p>Статус: ${dataStatus.projectParticipant}</p> `; } </script> <br><a href="../">Назад</a> </body> </html>