Create array with checkboxes using JavaScript
P粉905144514
P粉905144514 2024-02-26 08:50:20
0
1
318

I want to create a combo game using checkboxes to check in some elements

I need to create an array when the user selects a checkbox and compare it to the correct array

I don’t know who did it

This is my input

<section class="draggable-items">
    <div class="check-tool">
        <input type="checkbox"  class="checkbox-tool" name="tool" id="SBD710" value="SBD710">
        <img class="draggable correct" draggable="true" src="img-game/WOOD/SBD710.png">
    </div>
    <div class="check-tool">
        <input type="checkbox" class="checkbox-tool" name="tool"  id="SCS220" value="SCS220">
        <img class="draggable correct" draggable="true" src="img-game/WOOD/SCS220.png">
    </div>
    <div class="check-tool">
        <input type="checkbox" class="checkbox-tool" name="tool"  id="SB201" value="SB201">
        <img  class="draggable correct" draggable="true" src="img-game/WOOD/SB201.png">
    </div>
    <div class="check-tool">
        <input type="checkbox" class="checkbox-tool" name="tool"  id="SB204" value="SB204">
        <img class="draggable correct" draggable="true" src="img-game/WOOD/SB204.png">
    </div>
    <div class="check-tool">
        <input type="checkbox" class="checkbox-tool" name="tool"  id=SBG700" value="SBG700">
        <img  class="draggable correct" draggable="true" src="img-game/WOOD/SBG700.png">
    </div>


</section>
    <button id="check" class="btn">Construye</button>

If someone can explain how to create this array using Push method and who made it Compare with correct combined array

P粉905144514
P粉905144514

reply all(1)
P粉729518806

This is a demo of your solution


 let check = function () {
  let checkboxes = document.querySelectorAll("input[type=checkbox]");
  let result = [];
  for (let i = 0; i 



Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template