How to make automatic calculations using a checkbox?