fix page reload on submit

This commit is contained in:
Frieder Hannenheim 2025-01-29 18:48:14 +01:00
parent 154f04c202
commit 3930275c20
2 changed files with 7 additions and 6 deletions

View file

@ -38,8 +38,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<span class="focus"></span>
</div>
<form>
<div id="noten"></div>
<form id="noten">
<div id="noteninner"></div>
</form>
</div>

View file

@ -27,9 +27,10 @@ for (let key in studiengaenge) {
select.selectedIndex = 0;
var noten = document.getElementById("noten") as HTMLFormElement;
var notenInner = document.getElementById("noten") as HTMLDivElement;
select.onchange = function changed() {
noten.innerHTML = "";
notenInner.innerHTML = "";
let gewichtung_index = select.selectedOptions[0].value as keyof typeof studiengaenge;
let gewichtung = studiengaenge[gewichtung_index];
@ -68,7 +69,7 @@ select.onchange = function changed() {
row.insertCell().appendChild(label);
row.insertCell().appendChild(input);
}
noten.appendChild(table);
notenInner.appendChild(table);
let submit = document.createElement('input');
submit.type = "submit";
@ -76,8 +77,8 @@ select.onchange = function changed() {
let result = document.createElement('p');
noten.appendChild(result);
noten.appendChild(submit);
notenInner.appendChild(result);
notenInner.appendChild(submit);
noten.onsubmit = function calculate(event) {
event.preventDefault();