document.getElementById("saveButton").onclick = function() { var name =…
- User
document.getElementById("saveButton").onclick = function() { var name = document.getElementById("name").value; var age = document.getElementById("age").value; var city = document.getElementById("city").value; var company = document.getElementById("company").value; var email = document.getElementById("email").value; var tel = document.getElementById("tel").value; var comment = document.getElementById("comment").value;
if (name === "" || age === "" || city === "" || company === "" || email === "" || tel === "" || comment === "") { alert("Пожалуйста, заполните все поля."); } else { alert("Данные успешно сохранены"); var savedData = { "ФИО": name, "Возраст": age, "Город": city, "Компания": company, "Электронная почта": email, "Телефон": tel, "Описание компетенций и опыта": comment }; localStorage.setItem("savedData", JSON.stringify(savedData)); } return false;}; Ты мне до этого сделал чтобы на второй странице выводились данные, которые я ввожу в 1 странице, как сделать так чтобы очистить все данные во второй странице, чтобы первая осталась пустой?
- Assistant
To clear the data on the second page, you can remove the data from the local storage using the
localStorage.removeItem()method. Here's an example:localStorage.removeItem("savedData");You can call this code on the second page to remove the saved data from the local storage and ensure that the fields on the second page are empty.