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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="media/style.css">
<title>Document sans titre</title>
<script language="javascript">
var index = 1;
function loadData(valeur, indexLine) {
var data ;
var url = "ajax.php?reference=" + valeur;
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else return(false);
xhr_object.open("GET", url, false);
xhr_object.send(null);
if(xhr_object.readyState == 4) {
//alert(xhr_object.responseText);
data = eval(xhr_object.responseText);
document.getElementById("designation[" + indexLine + "]").value = data[1];
val_tarif=document.getElementById("tarif[" + indexLine + "]").value = data[2];
document.getElementById("colis[" + indexLine + "]").value = data[3];
document.getElementById("punet[" + indexLine + "]").value = data[2];
document.getElementById("total[" + indexLine + "]").value = data[2];
var n = 0;
//alert(n);
document.getElementById("montant_total").value = 0;
while ( document.getElementById("total[" + n + "]") )
{
//alert(document.getElementById("total[" + n + "]"));
document.getElementById("montant_total").value=
(parseFloat(document.getElementById("montant_total").value)+
parseFloat(document.getElementById("total[" + n + "]").value)).toFixed(2);
n++;
}
} else return(false);
}
function calcul_remise(value,indexLine){
var val_tarif=document.getElementById("tarif[" + indexLine + "]").value
var val_remise = document.getElementById("remise[" + indexLine + "]").value;
val_punet = val_tarif - (val_tarif*val_remise*1/100);
document.getElementById("punet[" + indexLine + "]").value = val_punet;
var quantite = document.getElementById("quantite[" + indexLine + "]").value;
var prix_total = quantite * val_punet;
document.getElementById("total[" + indexLine + "]").value = prix_total;
var n = 0;
//alert(n);
document.getElementById("montant_total").value = 0;
while ( document.getElementById("total[" + n + "]") )
{
//alert(document.getElementById("total[" + n + "]"));
document.getElementById("montant_total").value=
(parseFloat(document.getElementById("montant_total").value)+
parseFloat(document.getElementById("total[" + n + "]").value)).toFixed(2);
n++;
}
//alert(val_tarif);
}
function calcul_quantite(value,indexLine){
var val_punet=document.getElementById("punet[" + indexLine + "]").value
var quantite = document.getElementById("quantite[" + indexLine + "]").value;
var prix_total = quantite * val_punet;
document.getElementById("total[" + indexLine + "]").value = prix_total;
//alert(val_tarif);
var n = 0;
//alert(n);
document.getElementById("montant_total").value = 0;
while ( document.getElementById("total[" + n + "]") )
{
//alert(document.getElementById("total[" + n + "]"));
document.getElementById("montant_total").value=
(parseFloat(document.getElementById("montant_total").value)+
parseFloat(document.getElementById("total[" + n + "]").value)).toFixed(2);
n++;
}
}
function addLine() {
var newRow = document.getElementById('matable').insertRow(-1);
var reference = newRow.insertCell(0);
reference.innerHTML = '<input type="text" id="reference['+ index + ']" name="reference['+ index + ']" onChange="loadData(this.value, '+ index +')" />';
var designation = newRow.insertCell(1);
designation.innerHTML = '<input type="text" id="designation['+ index + ']" name="designation['+ index + ']" readonly />';
var quantite = newRow.insertCell(2);
quantite.innerHTML = '<input type="text" id="quantite['+ index + ']" name="quantite['+ index + ']" value="1" onChange="calcul_quantite(this.value, '+ index +')" />';
var colis = newRow.insertCell(3);
colis.innerHTML = '<input type="text" id="colis['+ index + ']" name="colis['+ index + ']" value="" />';
var remise = newRow.insertCell(4);
remise.innerHTML = '<input type="text" id="remise['+ index + ']" name="remise['+ index + ']" value="" onChange="calcul_remise(this.value, '+ index +')" />';
var tarif = newRow.insertCell(5);
tarif.innerHTML = '<input type="text" id="tarif['+ index + ']" name="tarif['+ index + ']" value="" readonly />';
var punet = newRow.insertCell(6);
punet.innerHTML = '<input type="text" id="punet['+ index + ']" name="punet['+ index + ']" value="" />';
var total = newRow.insertCell(7);
total.innerHTML = '<input type="text" id="total['+ index + ']" name="total['+ index + ']" value="" />';
index++;
}
function deleteLine() {
var nb = document.getElementById('matable').rows.length;
if(nb > 2){
//alert(nb);
document.getElementById('matable').deleteRow(-1);
}
var n = 0;
//alert(n);
document.getElementById("montant_total").value = 0;
while ( document.getElementById("total[" + n + "]") )
{
//alert(document.getElementById("total[" + n + "]"));
document.getElementById("montant_total").value=
(parseFloat(document.getElementById("montant_total").value)+
parseFloat(document.getElementById("total[" + n + "]").value)).toFixed(2);
n++;
}
alert(n);
}
/*function somme(){
var n = 0;
//alert(n);
document.getElementById("montant_total").value = 0;
while ( document.getElementById("total[" + n + "]") )
{
//alert(document.getElementById("total[" + n + "]"));
document.getElementById("montant_total").value=
parseInt(document.getElementById("montant_total").value)+
parseInt(document.getElementById("total[" + n + "]").value);
n++;
}
}*/
</script>
</head>
<body>
<p> </p>
<p> </p>
<p> </p>
<form method="post" action="commande.php">
<table id="matable" width="1048" border="0">
<tr>
<td width="111"><strong>REFERENCE</strong></td>
<td width="131"><strong>DESIGNATION</strong></td>
<td width="66"><strong>Quantité</strong></td>
<td width="94"><strong>COLIS</strong></td>
<td width="138"><strong>Remise(%)</strong></td>
<td width="157"><strong>TARIF(FCFA)</strong></td>
<td width="143"><strong>PU NET (FCFA)</strong></td>
<td width="174"><strong>TOTAL (FCFA)</strong></td>
</tr>
<tr>
<td width="111"><input type="text" id="reference[0]" name="reference[0]" onChange="loadData(this.value, 0)" /></td>
<td width="131"><input type="text" id="designation[0]" name="designation[0]" readonly /></td>
<td width="66"><input type="text" id="quantite[0]" name="quantite[0]" value="1" onChange="calcul_quantite(this.value, 0)" /></td>
<td width="94"><input type="text" id="colis[0]" name="colis[0]" value="" /></td>
<td width="138"><input type="text" id="remise[0]" name="remise[0]" value="" onChange="calcul_remise(this.value, 0)" /></td>
<td width="157"><input type="text" id="tarif[0]" name="tarif[0]" value="" readonly /></td>
<td width="143"><input type="text" id="punet[0]" name="punet[0]" value="" /></td>
<td width="174"><input type="text" id="total[0]" name="total[0]" value="" /></td>
</tr>
</table>
<table width="1367" id="matable2">
<tr>
<td width="87"></td>
<td width="103"></td>
<td width="51"></td>
<td width="73"></td>
<td width="108"></td>
<td width="124"></td>
<td width="157"></td>
<td width="291"></td>
<td width="333"><strong>Montant Total:</strong><input type="text" id="montant_total" name="montont_total" value="" /></td>
</tr>
</table>
<input type="button" name="button" id="button" value="Ajouter" onClick="addLine()" />
<input type="button" name="button3" id="button3" value="Supprimer" onClick="deleteLine()" />
<input type="submit" name="button2" id="button2" value="Valider" />
</form>
</body>
</html>
</html> |
Partager