i am creating a system in which there is a table and data is displayed dynamically in the table now for every row there is checkbox! what actually i am doing this when the user check on specific rows through checkbox i want to get that whole row in the format of something like given below e.g
object [
0: {
brandname:"brand_value",
createdon:"createdon_value"
.
.
.
},
{
1:brandname:"brand_value",
createdon:"createdon_value"
.
.
.
}
]
now what i done so far
PHP
$obj = "{".$r['brand'].",".$r['production_date'].",".$r['expiry_date'].",".$r['madein'].",".$r['status'].",".$r['batch_code'].",".$r['created_on']."}";
echo "<th id='not2'><input type='checkbox' name='checkedvalues' value='".$obj."'/> </th>";
now what i am doing is i am creating an object(which is not working as i want it to be) and echoing out the value in every checkbox value attribute so that i can get that checked values in jquery
JQuery Function
$.each($("input[name='checkedvalues']:checked"), function(){
selectedvalues.push($(this).val());
});
this is actually where the problem begins i need unique index with separated key and values e.g index 0 should contain data with key being brand and a value against it! because i need to access the the keys associated with an index individually ,now the problem!
selectedvalues.forEach(function(item, index, selectedvalues) {
console.log(index , item);
});
when i print this array it is showing me in the following format
0 {asdsa,2017-09-05,2017-09-13,asda,asdsa,WRCTG8O,2017-09-27}
1 {asdsa,2017-09-05,2017-09-13,asda,asdsa,WRCAbc2,2017-09-27}
it is actually creating an index and assigning all the values to that index whereas i want to access the values in an index using keys e.g 0 index value through key ,which e.g is brand="brand_Value" ! just like we do in php we create an associative array an and in key we put index and in value we put another array with keys and values, any help?