Na egzaminie często trzeba zebrać dane z kilku inputów i coś z nimi zrobić (wyświetlić, policzyć, połączyć).
getElementById,
a potem składasz wynik w jedną wiadomość lub obliczenie.
function pokazDaneA() {
let imie = document.getElementById("imieA").value;
let nazwisko = document.getElementById("nazwiskoA").value;
let wiek = document.getElementById("wiekA").value;
document.getElementById("wynikA").innerHTML =
"Uczeń: " + imie + " " + nazwisko + ", lat: " + wiek;
}
const produktB = document.getElementById("produktB");
const iloscB = document.getElementById("iloscB");
const cenaB = document.getElementById("cenaB");
const wynikB = document.getElementById("wynikB");
document.getElementById("btnB").addEventListener("click", function() {
let nazwa = produktB.value;
let ile = Number(iloscB.value);
let cena = Number(cenaB.value);
let suma = ile * cena;
wynikB.innerHTML = nazwa + " × " + ile + " = " + suma.toFixed(2) + " zł";
});
document.getElementById("btnC").onclick = () => {
const od = document.getElementById("odC").value;
const do_ = document.getElementById("doC").value;
const km = document.getElementById("kmC").value;
document.getElementById("wynikC").innerHTML =
`Trasa: ${od} → ${do_} (${km} km)`;
};