I have to form a JSON object like
var SelectedRows= {
"item1":{"id":"1","name":"jhon","phone":"6699"},
"item2":{"id":"2","name":"Aron","phone":"7799"},
"item2":{"id":"3","name":"Iyan","phone":"8899"},
}
On check box click event, I need to add the grid row values to the JSON list. I am trying with this code:
var SelectedRows={};
$(this).delegate(":checkbox", "click", function() {
var j=0;
var item=[];
SelectedRows[item]={}; *//I guess this line creating problem*
$(this).closest("tr").find("td:visible").each(function(){
var key=headerRow[j]["i"];
if(j == 0)
{
}
else
{
SelectedRows[item][key]=$(this).text();
}
j=++j;
});
After multiple checkbox click events happening,SelectedRows contains only last click event data.
How get all the checkboxes click events data?
var item[];is not valid Javascript, what are you trying to do with that?item.