Change the value of a checkbox using a Java script

can I change the value of a checkbox using a Java script in the DOM of the browser page?

It is necessary that the value remains the next time the form is loaded.

I tried several methods, but it only worked to visually check the box. When you clicked again, the checkbox was updated to a real one, and when submitting the form, a message was displayed that there was no checkmark at all