I am thinking this is doable? Maybe?
Here is my checkbox input:
<input type='checkbox' name='cb_name' id='cb_name' checked='checked' />
I Need an if else statement that checks only if the Checkbox was changed.
I have other input fields on the form. And if the checkbox wasn’t touched or checked, then SAVE the form without doing the checkbox condition.
If checkbox was checked before and now is != ‘checked’ then do this.
&&
If checkbox was != ‘checked’ before and now is = ‘checked’ then do this.
&&
and then finally, if checkbox was left alone (NO VALUE WAS CHANGED) then do the other form stuff without running the checkbox condition statement??
To do this, you must have some reason to decide when displaying the form if the check box is checked or not. This is your initial state.
Because we don’t know how you are deciding this, why not add a hidden field with the value like so, setting the value to match if the checkbox is checked (ie checked/unchecked):
We don’t know your condition for why the checkbox is checked, however this should solve the simple idea abstractly
Then when you get your post data
This is a solution without needing previous state