Advertisement
MariaIvanovaMihova

JS Advanced Exam - 25 Jun 2022

Oct 7th, 2022
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.addEventListener("load", solve);
  2.  
  3. function solve() {
  4.   const make = document.getElementById("make");
  5.   const model = document.getElementById("model");
  6.   const year = document.getElementById("year");
  7.   const fuel = document.getElementById("fuel");
  8.   console.log(fuel.value);
  9.   const originalCost = document.getElementById("original-cost");
  10.   const sellingPrice = document.getElementById("selling-price");
  11.  
  12.   // if (
  13.   //   Number(originalCost.value > Number(sellingPrice.value)) ||
  14.   //   make.value == "" ||
  15.   //   model.value == "" ||
  16.   //   year.value == "" ||
  17.   //   fuel.value == ""
  18.   // ) {
  19.   //   return;
  20.  
  21.   const publishBtn = document.getElementById("publish");
  22.   const table = document.getElementById("table-body");
  23.  
  24.   publishBtn.addEventListener("click", function () {
  25.     console.log(make.value);
  26.     console.log(model.value);
  27.     console.log(year.value);
  28.     console.log(fuel.value);
  29.     console.log(originalCost.value);
  30.     console.log(sellingPrice.value);
  31.     const tr = document.createElement("tr");
  32.     tr.classList.add("row");
  33.     tr.innerHTML = `
  34.     <td>${make.value}</td>
  35.     <td>${model.value}</td>
  36.     <td>${year.value}</td>
  37.     <td>${fuel.value}</td>
  38.     <td>${originalCost.value}</td>
  39.     <td>${sellingPrice.value}</td>
  40.     <td>
  41.     <button class='action-btn edit'>Edit</button>
  42.     <button class='action-btn sell'>Sell</button>
  43.     </td>
  44.     `;
  45.     table.appendChild(tr);
  46.   });
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement