Moved code into function

This commit is contained in:
gpkvt 2023-06-05 10:31:28 +02:00
parent 2e0bc3764f
commit 07a34b1b12
1 changed files with 10 additions and 10 deletions

View File

@ -29,6 +29,14 @@ function checkCount() {
return false;
}
function check(choice) {
value = checkedGroups[0];
removeId();
getid = choice+value;
document.getElementById(getid).checked = true;
checkCount();
}
window.addEventListener("keydown", function (event) {
if (event.defaultPrevented) {
return;
@ -40,18 +48,10 @@ window.addEventListener("keydown", function (event) {
switch (event.key) {
case "a":
value = checkedGroups[0];
removeId();
getid = 'a'+value;
document.getElementById(getid).checked = true;
checkCount();
check("a");
break;
case "b":
value = checkedGroups[0];
removeId();
getid = 'b'+value;
document.getElementById(getid).checked = true;
checkCount();
check("b");
break;
default:
checkCount();