Skip to content
Advertisement

how to update a checkbox value on update function on request based?

i written a very simple code to update value of checkbox but it update 1 in db on uncheck it doesnot update 0 if request is submit here is code

JavaScript

controller side

JavaScript

what mistake in it?

Advertisement

Answer

the input type “checkbox” does not return values when unchecked.

Two solutions to choose from :

In PHP :

JavaScript

In HTML :

Force a first return to “0” to force the update of the database. This value will be overrided if the checkbox is “1” :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement