bonjour
j'ai un formulaire commande et j'ai 2 tables Produit et commande
je veux effectuer un test coté client : "est- ce que la quantité commandée saisie par le client est superieure à la quantité en stock ?"
si oui affiche moi un message
pour cela j'ai fais ce code mais malheureusement ça ne marche pas
j'ai introduit php dans javascript
voila ce que j'ai fais
quand je saisis une quantité suppérieure à la quantité en stock je ne vois aucun message
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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<html> <head><meta http-equiv="Content-Language" content="ar-tn"> //javascipt// function test(form1){ <?php $ref ?>=document.form1.refp.value; <?php include"connexion.php"; $result=mysql_result(mysql_query("select qts_pack from pack where lib_pack='$ref'") or die("erreur sql". mysql_error())); mysql_close(); ?> if(document.form1.qt.value> <?php echo'$result'; ?>){ alert("attention qtcde > qt en stock !!"); } } </script> <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"><title>Commande</title></head> <body> <form method="POST" action="ecriture_cde.php" id="form1"> Libellé produit <select name="refp_cde" id="refp" > <option value="">---</option> <?php include"connexion.php"; $sql="select * from pack"; $req=mysql_query($sql) or die("Error en sql".mysql_error()); while($l=mysql_fetch_array($req)) { echo'<option value="'.$l['ref_pack'].'">'.$l['lib_pack'].'</option>'; } mysql_close(); ?> </select> Qt cde : <input name="qt_cde" type="text" size="6" id="qt" onblur="test(form1)"/> // test apres la perte focus// </form> </body> </html>
merci de m'aider svp







Répondre avec citation
Partager