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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<title>Demo</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" />
</head>
<body>
<?PHP
include ("./include/mes_fonctions.php");
open_db();
if ( !isset($_PUT['no_cli']) )
{
$no_cli='';
$nom='';
$prenom='';
$tot_lg='0';
}
?>
<form action='' method='post'>
<p><label>Client :</label><input type='text' name='numero' id='cherche'></input>
<label>Nom :</label><input type='text' id='nom' name='nom' ></input>
<label>Prénom :</label><input type='text' id='prenom' name='prenom' ></input></p>
<?PHP
for ($i=0 ; $i < 5 ; $i++)
{
?>
<p>
<label>Référence :</label><input type='text' name='reference[]' class='produit' ></input>
<label>Libellé :</label><input type='text' name='libelle[]' class='libelle' ></input>
<label>Prix :</label><input type='text' class='prix' name='prix[]' ></input>
<label>Qté :</label><input type='text' class='qte' name='qte[]' onkeyup = "javascript:calcul('tot_lg');"></input>
<label>Total :</label><input type='text' class='tot_lg' name='tot_lg[]' value="<?PHP echo $tot_lg ?>" readonly></input>
</p>
<?PHP
}
?>
<p>
<label>Total commande :</label><input type='text' name='tot_cmd' id='tot_cmd' readonly></input>
</p>
</form>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.2/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
dataType: 'json';
//autocomplete
$("#cherche").autocomplete({
source: "getautocomplete.php",
minLength: 3,
select : function(event, ui)
{
$('#cherche').val( ui.item.value ),
$('#nom').val( ui.item.nom ),
$('#prenom').val( ui.item.prenom );
}
});
});
</script>
<script type="text/javascript">
$(function() {
dataType: 'json';
$(".produit").autocomplete({
source: "rech_produits.php",
minLength: 3,
select : function(event, ui)
{
$('.libelle').val( ui.item.libelle ),
$('.prix').val( ui.item.prix );
}
});
});
</script>
<script type="text/javascript">
function calcul()
{
/* La quantité est celle tapée dans le formulaire */
var quantite = document.getElementById("qte").value;
var prix = document.getElementById("prix").value;
/* Calcul du total et affichage */
var total = parseFloat(quantite) * parseFloat(prix);
document.getElementById('tot_lg').value = total.toFixed(2);
var total_commande = document.getElementById('tot_cmd').value + parseFloat(total);
document.getElementById('tot_cmd').value = total.toFixed(2);
}
</script>
</body>
</html> |
Partager