Untitled
unknown
html
a year ago
2.8 kB
11
Indexable
Never
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> table,tr,td,th{ border:1px solid; border-collapse:collapse; } tr{ width:30px; } </style> </head> <body> <table> <th>nazwa </th><th>ilosc</th><th>aktualizuj</th><th>zamówienie</th> <tr><td class="klasa1">a</td><td class="wartosc">11</td><td><input type="button" onclick="zmiana()" value="zmien"></td><td><input type="button" onclick="zamow(1)" value="zamow"></td> </tr> <tr><td id="test1">b</td><td class="wartosc">3</td><td><input type="button" onclick="zmianatest1()" value="zmien"></td><td><input type="button" onclick="zamow(2)" value="zamow"></td> </tr> <tr><td class="klasa1">c</td><td class="wartosc">3</td><td><input type="button" onclick="zmianaklasa1()" value="zmien"></td><td><input type="button" onclick="zamow(3)" value="zamow"></td> </tr> <tr><td >d</td><td class="wartosc">43</td><td><input type="button" onclick="zmianaqall()" value="zmien"></td><td><input type="button" onclick="zamow(4)" value="zamow"></td> </tr> </table> <input type="button" onclick="czymalo()"> <script> function zamow(a){ let ilosc=parseInt(prompt("Podaj o ile zmienić zamowienie")); document.write(`do zamowienia ${a} dodano ${ilosc} towaru`); let pierwotnailosc=document.querySelectorAll("td").textContent; let pierwotnailoscliczba= pierwotnailosc[a-1]; document.write(pierwotnailoscliczba); } function czymalo(){ let analizowana = document.querySelectorAll("td"); for(let i =1;i<analizowana.length;i=i+4){ wartosckomorki=parseInt(analizowana[i].textContent) if (wartosckomorki>10){ analizowana[i].style.backgroundColor="green"; } else{ analizowana[i].style.backgroundColor="red"; } } } function zmiana(){ document.querySelector("td").style.backgroundColor="green"; } function zmianatest1(){ document.querySelector("#test1").style.backgroundColor="red"; } function zmianaklasa1(){ document.querySelector(".klasa1").style.backgroundColor="yellow"; } function zmianaqall(){ let komorka=document.querySelectorAll("td"); for(let i=0;i<komorka.length; i++){ komorka[i].style.backgroundColor="blue"; } } </script> </body> </html>