I am trying to push the value of each check box value inside the array but every it pushes same data twice or as many checkbox i select if I choose 3 checkbox and the last check has the value of 2 so it is pushing 3 into the array 3 times and not storing the value of other two
The Jquery Code:
$('#data_table').append("<tr>"+"<td><input type='checkbox' class='checkbox' name='check' id='checked_box"+j+"' value='"+time+" 'onclick='myFunction(this)' ></td>" +"<td>"+sites.siteName +"</td>"+ "<td>" + values.deviceName + "</td>" + "<td>" + values.count + "</td>" + "<td>" + parseFloat(time).toFixed(2) + " Min" + "</td>" + "</tr>");
The Javascript Code:
var check_id=e.getAttribute('id');
var time = document.getElementById(check_id).value;
var values = [];
for(var j=0 ; j<time.length ; j++){
if(checkboxes[j].checked){
values.push(time);
}
}
console.log(values);
I just want to get the checkbox values and add it up and show the total but as i mentioned it is pushing the same data as many times i select a checkbox
Please solve this problem for me, Any help will be highly appreciable......