lundi 9 octobre 2017

Updating checkbox each time it is checked or unchecked

I have a 6 checkboxes checked/unchecked based on values from the database, the 5th checkbox is unchecked, to get the state, I use the snippet below:

var allCheckboxes = $(':input[name="cc_checkbox"]').map(function () {
  return this.value;
}).get();

when I console.log(allCheckboxes) I get ["1", "1", "1", "1", "0", "1"] which is right.

But when I check/uncheck any of the checkboxes and console.log(allCheckboxes), I still get ["1", "1", "1", "1", "0", "1"]

Is this a normal a behaviour or is there some other syntax I need to use?




Aucun commentaire:

Enregistrer un commentaire