I've run into a bit of an issue. Here's a brief explanation.
I have 12 check boxes on a standard form. What I need to do is loop through each of them and learn which ones are checked and which ones are unchecked.
Using this, I can then build a string which I then enter into a database field. Here is an example.
(Check1 - checked)
(Check2 - not checked)
(Check3 - checked)
1,0,1
So far, I've got this bit of code.
$('input[type=checkbox]').each(function () {
if (this.checked) {
console.log($(this).val());
}
});
It works perfectly except that it only brings back the checked ones, not all.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…