Skip to content
Advertisement

How to uncheck checkbox on option select then load corresponding data from database and persist checkbox and option select state

I have a checkbox and a select option on my page that displays data from my database.

I want a situation where when a user checks the checkbox,then the word “All” will be displayed in the select option and all data displayed on table. Then when a user selects any option from the drop-down,the checkbox should be unchecked and the corresponding rows of data displayed as selected by user.

I’m still learning my way through with JavaScript and jQuery. I know its solution lies there but I don’t know just how to get about it. Below is what I’ve tried following similar cases but it hasn’t solved my problem.

My html for the check box and select

JavaScript

Below is the jquery code:

JavaScript

Advertisement

Answer

Perhaps the following MIGHT help a little – though I notice you have added some Javascript which uses localStorage to maintain checkbox checked state seeminly which was not specified in the original code/question.

JavaScript

Notes on the identified portion of code

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