richarddunnebsc
Active Coder
I am using
If a checkbox id is in an array of id's (not equal to -1), and is checked, increase a count by 1. This works.
If a checkbox is unchecked, decrease the count by one, count--. When I display the count after count-- is applied, the count is -1, not 0.
Why did the count decrease by 2 instead of 1?
So I used alert() to display the count before and after the decrease. After unchecking the box, alert displays 0, not 1 as I expected. Why did it decrease the count by 1 before applying count--?
Obviously, this is meant to happen?
So, after unchecking the checkbox, I don't need to use count--, the count decreases automatically. Is this normal/expected behaviour?
JavaScript:
jQuery.inArray()
If a checkbox is unchecked, decrease the count by one, count--. When I display the count after count-- is applied, the count is -1, not 0.
Why did the count decrease by 2 instead of 1?
So I used alert() to display the count before and after the decrease. After unchecking the box, alert displays 0, not 1 as I expected. Why did it decrease the count by 1 before applying count--?
Obviously, this is meant to happen?
So, after unchecking the checkbox, I don't need to use count--, the count decreases automatically. Is this normal/expected behaviour?