-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (22 loc) · 902 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
document.getElementById("compundInterestForm").addEventListener("submit", function(event) {
event.preventDefault();
const principal = document.getElementById("principal").value;
const rate = document.getElementById("rate").value;
const time = document.getElementById("time").value;
fetch(`API.php?principal=${principal}&rate=${rate}&time=${time}`)
.then(response => response.json())
.then(data => {
const resultsTable = document.getElementById("resultsTable");
let tableContent = "";
data.forEach(item => {
tableContent += `
<tr>
<td>${item.year}</td><td>${item.amount} $</td>
</tr>
`;
});
resultsTable.querySelector("tbody").innerHTML = tableContent;
resultsTable.style.display = "table";
})
.catch(error => console.error("Błąd:", error));
});