user.service.js 665 B

12345678910111213141516171819
  1. const userData = () => {
  2. const userName = document.getElementById('name').value;
  3. const userSurname = document.getElementById('surname').value;
  4. const userPhone = document.getElementById('phone').value;
  5. const userAddress = document.getElementById('address').value;
  6. if (userName && userPhone) {
  7. return {
  8. name: userName,
  9. surname: userSurname,
  10. phone: userPhone,
  11. address: userAddress
  12. }
  13. }
  14. }
  15. document.querySelector('.user-info').onsubmit = function (event) {
  16. event.preventDefault();
  17. localStorage.setItem('userInfo', JSON.stringify(userData()));
  18. window.open('./cart.html')
  19. }