I have multiple checkboxes and these have values and title attributes. Here titles are represent group So when i check any checkbox they will store as Json multidimensional array.
Html :
<span>
<input type="checkbox" value="4" title="23">
<input type="checkbox" value="5" title="23">
<input type="checkbox" value="2" title="24">
</span>
Json Code (i want like this:)
[
"23":{
"id":"4",
"id":"5"
},
"24":{
"id":"2"
}
]
And When i uncheck checkbox values remove from group of array and when no value checked from group of array Group will be remove.
I did Code :
$('span').find('input[type=checkbox]').click(function(event) {
var searchData = $('input:checkbox:checked').map(function() {
return this.value;
}).get();
$("#hsearchData").val(searchData);
});
Aucun commentaire:
Enregistrer un commentaire