Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let sendFormElement = document.querySelector('button');
- sendFormElement.addEventListener('click', (e) => {
- let inputElements = document.querySelectorAll('#description, #client-name, #client-phone');
- inputElements = Array.from(inputElements);
- let arrOfInpEl = inputElements.map(el => el.value);
- if (!arrOfInpEl.includes('')) {
- let productType = document.getElementById('type-product').value;
- let clearButtonElement = document.querySelector('.clear-btn');
- let recvOrdersSection = document.getElementById('received-orders');
- let compOrdersSection = document.getElementById('completed-orders');
- let divContainer = document.createElement('div');
- divContainer.classList.add('container');
- let h2El = document.createElement('h2');
- let h3El = document.createElement('h3');
- let h4El = document.createElement('h4');
- let buttonStart = document.createElement('button');
- let buttonFinish = document.createElement('button');
- buttonStart.textContent = 'Start repair';
- buttonFinish.textContent = 'Finish repair';
- buttonStart.classList.add('start-btn');
- buttonFinish.classList.add('finish-btn');
- buttonFinish.disabled = true;
- h2El.textContent = `Product type for repair: ${productType}`;
- h3El.textContent = `Client information: ${inputElements[1].value}, ${inputElements[2].value}`;
- h4El.textContent = `Description of the problem: ${inputElements[0].value}`;
- divContainer.appendChild(h2El);
- divContainer.appendChild(h3El);
- divContainer.appendChild(h4El);
- divContainer.appendChild(buttonStart);
- divContainer.appendChild(buttonFinish);
- recvOrdersSection.appendChild(divContainer);
- for (el of inputElements) {
- el.value = '';
- }
- buttonStart.addEventListener('click', (e) => {
- buttonStart.disabled = true;
- buttonFinish.disabled = false;
- });
- buttonFinish.addEventListener('click', (e) => {
- divContainer.removeChild(buttonStart);
- divContainer.removeChild(buttonFinish);
- compOrdersSection.appendChild(divContainer);
- });
- clearButtonElement.addEventListener('click', (e) => {
- compOrdersSection.removeChild(compOrdersSection.lastChild);
- });
- }
- event.preventDefault();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement