Mi objetivo es que el botón "kampfende" restablezca las casillas de verificación debajo de la identificación "aktionspunkte". He leído que una función de reinicio no funciona con casillas de verificación, por eso lo probé con if/else, pero no sucede nada en este momento.
Un poco más sobre el código: El botón "Nächste Runde" le dice al usuario que agregue 3 ap a los actuales y establece el contador "Kamprunden" en +1. Eso funciona totalmente bien. El botón "kampfende" restablece el contador "Kampfrunde", que también funciona bien.
No estoy seguro si puedo construir el if-else en la función de reinicio y también si puedo escribir dos funciones para un botón.
¡Sería bueno si me puedes ayudar!
código actual:
var kampfrundencounter = (function() { var runde = 1; return function(reset = false) { runde = reset ? 1 : runde + 1 return runde; } })(); function rundeErhöhen() { document.getElementById("kampfrundencounter").innerHTML = kampfrundencounter(); alert("Füge 3 Aktionspunkte zu deinen hinzu"); } function reset() { document.getElementById("kampfrundencounter").innerHTML = kampfrundencounter(true); //maybe here the if-else-part like: if the ap1- checkbox is uncheck then check it, if the ap2 checkbox is uncheck then check it, ...., if the ap5 is checked then uncheck it, .... } <div id = "Aktionspunkte"> <!--AKtionspunkte + Checkboxen--> <input type="checkbox" name="aktionspunkt" id="ap1" checked> <input type="checkbox" name="aktionspunkt" id="ap2" checked> <input type="checkbox" name="aktionspunkt" id="ap3" checked> <input type="checkbox" name="aktionspunkt" id="ap4" checked> <input type="checkbox" name="aktionspunkt" id="ap5"> <input type="checkbox" name="aktionspunkt" id="ap6"> <input type="checkbox" name="aktionspunkt" id="ap7"> <input type="checkbox" name="aktionspunkt" id="ap8"> </div> <div> <!--Kamprundencounter--> <button type="button" id="neueRunde" onclick="rundeErhöhen()">Nächste Runde</button> <button type="button" id="kampfende" onclick="reset()">Kampfende</button> <p>Aktuelle Runde: <a id="kampfrundencounter">1</a> </p> </div>