Advertisement
bebo231312312321

Untitled

Jun 15th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.   const makeInput = document.getElementById('make');
  3.   const modelInput = document.getElementById('model');
  4.   const productionInput = document.getElementById('year');
  5.   const fuelType = document.getElementById('fuel');
  6.   const originPrice = document.getElementById('original-cost');
  7.   const sellPrice = document.getElementById('selling-price');
  8.   const ulCarsList = document.getElementById('cars-list');
  9.   const profit = document.getElementById('profit');
  10.   const publishBtn = document.getElementById('publish');
  11.   const tbody = document.getElementById('table-body');
  12.  
  13.   publishBtn.addEventListener('click', onPublish)
  14.  
  15.   function onPublish(e) {
  16.     e.preventDefault();
  17.  
  18.     let make = makeInput.value
  19.     let model = modelInput.value
  20.     let product = Number(productionInput.value)
  21.     let fuel = fuelType.value
  22.     let oPrice = Number(originPrice.value);
  23.     let sPrice = Number(sellPrice.value)
  24.  
  25.     if (sPrice <= oPrice || !make || !model || !product || !fuel)  return;
  26.  
  27.     let publish = onCreate(make, model, product, fuel, oPrice, sPrice)
  28.     tbody.appendChild(publish)
  29.  
  30.     makeInput.value = "";
  31.     modelInput.value = "";
  32.     productionInput.value = "";
  33.     fuelType.value = "";
  34.     originPrice.value = "";
  35.     sellPrice.value = "";
  36.  
  37.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement