I have a table that feeds on the following json file
[
{"id":"1","rank":"9","content":"Alon","UID":"5","P1":"1","P2":"0","P3":"0","P4":"1","P5":"0"},
{"id":"2","rank":"6","content":"Tala","UID":"6","P1":"1","P2":"0","P3":"0","P4":"1","P5":"0"},
{"id":"3","rank":"9","content":"Alon","UID":"5","P1":"1","P2":"0","P3":"0","P4":"1","P5":"0"},
{"id":"4","rank":"6","content":"Tala","UID":"6","P1":"1","P2":"0","P3":"0","P4":"1","P5":"0"},
{"id":"5","rank":"6","content":"Tala","UID":"6","P1":"1","P2":"0","P3":"0","P4":"1","P5":"0"}]
then use jquery to fill the table.
$.ajax({
url: 'test.json',
type: 'POST',
success: function (response) {
var trHTML = '';
var valueOn = 1;
var valueOff = 0;
$.each(response, function (i, item) {
trHTML += '<tr><td>' + item.rank + '</td><td>' + item.content + '</td><td>' + item.UID + '</td><td>' + '<input type="checkbox" value="' + item.P1 + '"></td><td>' + '<input type="checkbox" value="' + item.P2 + '"></td><td>' + '<input type="checkbox" value="' + item.P3 + '"></td><td>' + '<input type="checkbox" value="' + item.P4 + '"></td><td>' + '<input type="checkbox" value="' + item.P5 + '"></td></tr>';
});
$('#records_table').append(trHTML);
$('input[type="checkbox"]').each(function () {
if ( $(this).val() == valueOn ) {
$(this).attr("checked",true);
}
if ( $(this).val() == valueOff ) {
$(this).attr("checked",false);
}
});
$('tr:odd').css("background", "green");
},
error: function (response) {
console.log('shit shit shit!!!! now see me running!');
},
});
my question is how is how I can build an array containing a list of changed chebox with the id
Aucun commentaire:
Enregistrer un commentaire