Currently having a page where the admin can assign Contract from one worker to another worker.
My form (working)
<form id='form' name='form' method='POST' action='' style="width:80%!important;">
<label for='ra'>From :</label>
<SELECT name='ra' id='ra'>
<OPTION value=''>
<OPTION value={$res['idUtilisateur']}> {$res['USR_Login']} //added with statement
</SELECT>
<br/><br/>
<div id='devis'></div>
<label for='toRA'>To :</label>
<SELECT name='toRA' id='toRA'>
<OPTION value=''>
<OPTION value={$res['idUtilisateur']}> {$res['USR_Login']} //added with statement
</SELECT>
<input type='submit' name='submit' id='submit' value='Change'>
</form>
OPTION are added with sql statement, but I didn't display it.
When I select someone from my SELECT 'ra' (FROM), it displays all of his contracts in a table which checkboxes at each row which has the idContract for value and id.
My question is : How to manage my script.php to transfer every Contracts checked ?
My query would be :
UPDATE Contract
SET idUtilisateur = :idUser
WHERE idContract = :idContract
How to run it for each checkbox checked from my form ?
EDIT :
Table generating :
$(document).ready( function () {
$('#ra').change(function() {
if($('#ra').val()) {
$.ajax({
type: "GET",
url: "jsonDevisUtilisateur.php?ra=" + $('#ra').val(),
success: function(data) {
var table = "<table><tr><td>Numéro</td><td>Client</td><td>Site</td><td>Libellé</td><td></td></tr>"
for(var i=0; i<data.length; i++) {
table += "<tr><td>" + data[i].numDevis + "</td>";
table += "<td>" + data[i].client + "</td>";
table += "<td>" + data[i].site + "</td>";
table += "<td>" + data[i].libelle + "</td>";
table += "<td><input type='checkbox' value='"+data[i].id + "' name='"+data[i].id + "'></td></tr>"
}
table +="</table>";
document.getElementById('devis').innerHTML = table+"<br/><br/>";
}
});
} else document.getElementById('devis').innerHTML = "";
});
});
Aucun commentaire:
Enregistrer un commentaire