bonsoir j'ai un problème avec la récupération des valeurs des checkbox s'il sont checked
dans le fichier attaché vous trouvez la capture d'écran d'un tableau généré par une résultat d'ajax mais le problème que j'ai essayé d'avoir la valeur d'un checkbox
mais tous les codes ont ramené à des échecs .
voilà la fonction qui retourne le résultat (ajax)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| $('.clientcomm').on('change',function(){
tabl=$(this).attr('index');
var Tbl = document.getElementById('addtable');
while(Tbl.childNodes.length>2){Tbl.removeChild(Tbl.lastChild);}
idclient=$(this).val();
$.ajax({
url: wr+"Reglements/affichercommande/"+idclient,
dataType:"json",
}).done(function(data){
// console.log((data.commandes[0][0]));
for(i=0;i<(data.commandes).length;i++ )
{
if(data.commandes[i][0]['etat']=="0"){
text='<font color="red">Non Payé</font>';
check='<input type="checkbox" name="data[Commandes]['+i+'][etat]" value="1" class="checkmont" index="'+i+'" id="paiement'+i+'"';
}
else
{
text='<font color="green">Payé</font>';
check='';
}
$('#addtable').append('<tr>\n\
<td align="center" nowrap="nowrap"><input type="text" value="'+data.commandes[i][0]['id']+'" class="form-control col-sm-12" name="data[Commandes]['+i+'][id]" readonly id="cmd'+i+'" > </td>\n\
<td align="center" nowrap="nowrap"><input type="text" value="'+data.commandes[i][0]['date']+'" class="form-control col-sm-12" name="data[Commandes]['+i+'][date]" readonly id="datecmd'+i+'" ></td>\n\
<td align="center" nowrap="nowrap"><input type="text" value="'+data.commandes[i][0]['acompte']+'" class="form-control col-sm-12" name="data[Commandes]['+i+'][acompte]" readonly id="acomptecmd'+i+'" ></td>\n\
<td align="center" nowrap="nowrap"><input type="text" value="'+data.commandes[i][0]['total']+'" class="form-control col-sm-12" name="data[Commandes]['+i+'][total]" readonly id="totcmd'+i+'" ></td>\n\
<td align="center" nowrap="nowrap"><input type="text" value="'+Number(parseFloat(data.commandes[i][0]['total'])-parseFloat(data.commandes[i][0]['acompte'])).toFixed(3)+'" class="form-control col-sm-12" name="data[Commandes]['+i+'][total]" readonly id="totcmd'+i+'" ></td>\n\
<td align="center" >'+ text+' </td> \n\
\ <td align="center" >'+ check+' </td> \n\
</tr>');
}
});
}); |
Partager