import './style.css' const URL = "http://localhost:8000/index.php"; (async () => { const voivs = await (await fetch(URL)).json() as string[] const tbody = document.getElementById('tds-here') as HTMLTableSectionElement; for (const v of voivs) { const tr = document.createElement("tr") const td = document.createElement("td") td.innerText = v td.onclick = () => showCities(v, v); tr.appendChild(td) tbody.appendChild(tr) } })() async function showCities(n: string, id: string) { const res = await (await fetch(URL, { method: "POST", body: id, })).json() as string[] const nh = document.getElementById("name-here") as HTMLTableRowElement const vt = document.getElementById("vtds-here") as HTMLTableSectionElement vt.innerHTML = '' nh.innerHTML = `Miasta w ${n} (${res.length}, internet)` for (const c of res) { const tr = document.createElement("tr") const td = document.createElement("td") td.innerText = c tr.appendChild(td) vt.appendChild(tr) } }