Re: _javascript_ Problems

Okay, so I wanted to have a dynamic checkbox for each items on a particular page. I didn't have any problems achieveing that.

however, I am having trouble with changing the state. The checkbox would either remain checked, or unchecked, and clicking on it will not make any difference.

the code is below:

// toggle the value for a given Ttodo

const toggleTodo = function (id) {
    const todo = todos.find(function (todo) {
        return todo.id === id

    })
    if (todo !== undefined) {
        todo.completed != todo.completed

    }

}

// Setting up the checkbox.

checkbox.setAttribute("type", "checkbox")
    checkbox.checked = todo.completed
    todoEl.appendChild(checkbox)

    checkbox.addEventListener("change", function () {
        toggleTodo(todo.id)
})

Can you tell me why the state of the checkbox remains the same? Is there something wrong with the event listener?

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dark Eagle via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dark Eagle via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dark Eagle via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dark Eagle via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kaigoku via Audiogames-reflector

Reply via email to