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
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
var trEdit;
function ajouterLigneFacture() {
var tr = document.getElementById("generique").cloneNode(true);
tr.removeAttribute("id");
tr.style.display="";
document.getElementById("lignesFacture").tBodies[0].appendChild(tr);
}
function supprLigne(tr) {
document.getElementById("lignesFacture").deleteRow(tr.rowIndex);
}
function validRecherche() {
//alert('Validation de la recherche: injection du produit sélectionné, ...');
//la liste de recherche des articles
var sel = document.getElementById("articleSelectionne");
//l'opton sélectionnée
var opt = sel.options[sel.selectedIndex];
//l'article (code, libellé, au choix) à afficher
var article = opt.value + " - " + opt.text;
//la liste des inputs pour la ligne en cours d'édition
var inputs = trEdit.getElementsByTagName("input");
//on considère qu'on a uniquement des boites de type text
//sinon faire un boucle pour cibler l'input concerné
//on affiche dans la première zone de saisie
inputs[0].value = article;
//plus de sélection en cours
trEdit = null;
//on cache la recherche
document.getElementById("recherche").style.display="none";
}
function dispRecherche(tr) {
document.getElementById("recherche").style.display="block";
//on enregistre la ligne en cours d'édition
trEdit = tr;
}
</script>
</head>
<body>
<form action ="ttt.php" method="post">
<div id="entete">
Nom: <input type="text" name="nom" />
Adresse: <input type="text" name="adresse" />
</div>
<table border="1" id="lignesFacture">
<tr>
<th>produit</th>
<th>quantite</th>
<th>montant HT</th>
<th>Suppr.</th>
</tr>
<tr id="generique" style="display:none">
<td>
<input type="text" name="article[]"/><button type="button" onclick="dispRecherche(this.parentNode);">...</button></td>
<td><input type="text" name="quantite[]"/></td>
<td><input type="text" name="montant[]"/> €</td>
<td><button type="button" onclick="supprLigne(this.parentNode.parentNode)">Suppr</button></td>
</tr>
</table>
<button type="button" onclick="ajouterLigneFacture();">Ajouter ligne</button>
<input type="submit" value="Envoyer" />
</form>
<div id="recherche" style="background-color:yellow;display:none;z-order:1000">
<table>
<tr><td>Recherche d'un produit</td></tr>
<tr><td><input type="text" /> (filtre de recherche)</td></tr>
<tr><td><select id="articleSelectionne">
<option value="ART-001">Tennis</option>
<option value="ART-002">Kopa</option>
<option value="ART-003">Ballon</option>
<option value="ART-004">Canne à pêche</option>
<option value="ART-005">Baton de randonnée</option>
<option value="ART-006">Tente igloo</option>
<option value="ART-007">chronometre</option>
<option value="ART-008">Lunettes de glacier</option>
</select></td></tr>
<tr><td><button type="button" onclick="validRecherche();">Valider</button></td></tr>
</table>
</div>
</body>
</html> |