1

Temat: Zadanie na lekcji (4) - dokończyć w domu!!

https://ti.dxe.pl/files2/egz/ee_09_2022 … _kolor.pdf

2

Odp: Zadanie na lekcji (4) - dokończyć w domu!!

<script>
  function kolor(x)
  {
    var t1 = document.getElementById("t1");
    var p1 = parseInt(t1.innerHTML);
    var p2 = parseInt(t2.innerHTML);
    var p3 = parseInt(t3.innerHTML);
    var p4 = parseInt(t4.innerHTML);
    if (x == 1)
    {
      if (p1 == 0) t1.style.background = "red";
      else if (p1>=1 && p1<=5) t1.style.background = "yellow";
      else t1.style.background = "Honeydew";
    }
    if (x == 2)
    {
      if (p2 == 0) t2.style.background = "red";
      else if (p2>=1 && p2<=5) t2.style.background = "yellow";
      else t2.style.background = "Honeydew";
    }
    if (x == 3)
    {
      if (p3 == 0) t3.style.background = "red";
      else if (p3>=1 && p3<=5) t3.style.background = "yellow";
      else t3.style.background = "Honeydew";
    }
    if (x == 4)
    {
      if (p4 == 0) t4.style.background = "red";
      else if (p4>=1 && p4<=5) t4.style.background = "yellow";
      else t4.style.background = "Honeydew";
    }
  }
  function fun1(x)
  {
    var t1 = document.getElementById("t1");
    var t2 = document.getElementById("t2");
    var t3 = document.getElementById("t3");
    var t4 = document.getElementById("t4");
    //
    var p = prompt("Podaj ilość:", "");
    if (x == 1)
    {
      t1.innerHTML = p;
    }
    if (x == 2)
    {
      t2.innerHTML = p;
    }
    if (x == 3)
    {
      t3.innerHTML = p;
    }
    if (x == 4)
    {
      t4.innerHTML = p;
    }
    kolor(x);
  }
  function fun2(x)
  {
    var licznik = document.getElementById("licznik");
    licznik.value = parseInt(licznik.value)+1;
    if (x == 1) alert("Zamowienie nr: "+licznik.value+" Produkt: Skretka UTP drut");
    if (x == 2) alert("Zamowienie nr: "+licznik.value+" Produkt: Skretka UTP linka");
    if (x == 3) alert("Zamowienie nr: "+licznik.value+" Produkt: Wtyki 8P8C");
    if (x == 4) alert("Zamowienie nr: "+licznik.value+" Produkt: Modułu keystone");
  }
</script>
<body onload="kolor(1); kolor(2); kolor(3); kolor(4);">
<hr>
<table border="1" width="50%">
  <tr>
    <td>Produkt</td>
    <td>Jednostka</td>
    <td>Dostępnośc</td>
    <td>Aktualizacja</td>
    <td>Zamówienie</td>
  </tr>
  <tr>
    <td>Skretka UTP drut</td>
    <td>metr</td>
    <td id="t1">20</td>
    <td><button onclick="fun1(1)">Aktualizuj</button></td>
    <td><button onclick="fun2(1)">Zamów</button></td>
  </tr>
  <tr>
    <td>Skretka UTP linka</td>
    <td>metr</td>
    <td id="t2">2</td>
    <td><button onclick="fun1(2)">Aktualizuj</button></td>
    <td><button onclick="fun2(2)">Zamów</button></td>
  </tr>
  <tr>
    <td>Wtyki 8P8C</td>
    <td>sztuki</td>
    <td id="t3">10</td>
    <td><button onclick="fun1(3)">Aktualizuj</button></td>
    <td><button onclick="fun2(3)">Zamów</button></td>
  </tr>
  <tr>
    <td>Modułu keystone</td>
    <td>sztuki</td>
    <td id="t4">30</td>
    <td><button onclick="fun1(4)">Aktualizuj</button></td>
    <td><button onclick="fun2(4)">Zamów</button></td>
  </tr>
</table>
<hr>
<form>
  <input type="hidden" id="licznik" value="0">
</form>