Skip to content Skip to sidebar Skip to footer

How To Store Input Type Checkbox Into Json Object Using Either Javascript Or Jquery?

I wanted to store all my clicked input accordions() into json object, I have tried it but it is storing/taking the last input accordion clicked event o

Solution 1:

Because you are doing submitButtonValue[name] = $(this).val(); and the name you are getting it from $(this).attr('name'); on click of checkbox which is same for all the checkboxes. So everytime it replaces the value since object will have only one name contained. I would suggest you to either use different names for each checkbox or find some other way to uniquely store your checkbox values.

A Demo here

Post a Comment for "How To Store Input Type Checkbox Into Json Object Using Either Javascript Or Jquery?"