Update variable when checking checkbox

I have a script with some variables, & I would like to update one of these variables depending on the checkbox being checked or not. The checkbox is unselected by default. What I have now is this:

I would like to update the content of the variable “permission” based on a click event of a checkbox:

Fiddle here.

But how is that possible?

In order to update your object key (sv4) value:


If you already store the permission into your Object track, well, than don’t hesitate to use your object & directly manipulate it & setting a new value to it’s key using =.

Never forget to define internally your variables by setting var.

The $('#accept').is(':checked') uses the jQuery .is() method that returns a boolean (true/false) which than we set using Ternary Operator ( ? : ) to "Y" / "N"