Hello guys, i need help.
So,
HTML
<div id="profile-popup" class="popup">
<div class="popup__container">
<button type="button" class="popup__close" aria-label="Close"></button>
<h3 class="popup__name">edit profile</h3>
<form class="popup__form" name="profile" novalidate>
<label class="popup__label">
<input type="text" class="popup__input popup_n" name="username" required placeholder="name" minlength="2" maxlength="20">
</label>
<label class="popup__label">
<input type="text" class="popup__input popup_d" name="description" required placeholder="about you" minlength="3" maxlength="100">
</label>
<button type="submit" class="popup__submit" aria-label="Save">Save</button>
</form>
</div>
JS
let formElement = document.querySelector('.popup__form');
let username = document.querySelector('input[name="username"]');
let job = document.querySelector('input[name="description"]');
function handleFormSubmit (evt) {
evt.preventDefault();
document.getElementById('input[name="username"]').value;
document.getElementById('input[name="description"]').value;
document.querySelector('.popup_n').textContent = username;
document.querySelector('.popup_d').textContent = job;
}
formElement.addEventListener('popup__submit', handleFormSubmit);
it is necessary to enter new data and save (NO DB)
my task is to get data from input , enter new data and save them
2
Answers
I can’t comment unfortunately. If you like to save data without database. The most solution is to use a list of objects.
You must to create a function that push the new data to the list. Then if you need to call the info. use find method or another one.
You need to use a database if you think you don’t need use nodejs to save it to a .csv or .txt file, if you want to save it for short term locally you can use localStorage