Advertisement
Somo4k

JS advanced

Oct 12th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. window.addEventListener('load', solve);
  2.  
  3. function solve() {
  4.  
  5. const input = {
  6. typeProduct: document.getElementById('type-product'),
  7. description: document.getElementById('description'),
  8. clientName: document.getElementById('client-name'),
  9. clientPhone: document.getElementById('client-phone')
  10. }
  11.  
  12. const wrapper = {
  13. recievedOrdres: document.getElementById('received-orders'),
  14. completedOrders: document.getElementById('completed-orders')
  15.  
  16. }
  17.  
  18.  
  19. document.getElementsByTagName('button')[0].addEventListener('click', send)
  20. document.getElementsByTagName('button')[1].addEventListener('click', clear)
  21.  
  22. console.log(input);
  23.  
  24.  
  25. function send(e){
  26. event.preventDefault();
  27.  
  28. const typeProduct = input.typeProduct.value;
  29. const description = input.description.value;
  30. const clientName = input.clientName.value;
  31. const clientPhone = input.clientPhone.value;
  32.  
  33. if (description == '' || clientName == '' || clientPhone =='') {
  34. return;
  35. }
  36.  
  37. const div = document.createElement('div');
  38.  
  39. div.className = 'container';
  40. div.innerHTML = `<h2>Product type for repair: ${typeProduct}</h2>
  41. <h3>Client information: ${clientName}, ${clientPhone}</h3>
  42. <h4>Description of the problem: ${description}</h4>
  43. <button class="start-btn">Start repair</button>
  44. <button class="finish-btn" disabled>Finish repair</button>`;
  45.  
  46.  
  47. wrapper.recievedOrdres.appendChild(div);
  48.  
  49. input.description.value = '';
  50. input.clientName.value = '';
  51. input.clientPhone.value = '';
  52.  
  53.  
  54.  
  55. function repair(){
  56.  
  57. }
  58.  
  59. function finish(){
  60.  
  61. }
  62. }
  63.  
  64.  
  65. function clear(){
  66.  
  67.  
  68. }
  69.  
  70. }
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement