probleme avec 3 boutons...

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 14:11

Salut, en effet il s'agit plus d javascript (comme tu l'a dis), alors voila ce que je te propose:
le javascript:
<script language="javascript">
function action(NbRadio,chemin)
{	
  var m=0;
  for (i=0;i<=NbRadio;i++) 
  {
    if (document.forms.modif.id_produit[i].checked==true) 
	{
      m=document.forms.modif.id_produit[i].value;      
      break;
    }
  } 	
	window.location.replace(chemin+"?id="+m);
}
</script>	
Dans le formulaire:
<input type="button" onClick="action('<? echo $i; ?>','entree.php')" value="Entrées">
<input type="button" onClick="action('<? echo $i; ?>','modifier.php')" value="Modifier">
et ensuite tu récupere "l'id" grace a $_GET[id'].

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 15:08

merci pour ta reponse.

j'utilise ton code et j'ai un erreur. erreur en bas a gauche du navigateur qui me dit que le code n'est pas supporte.

ca vient du javascript???

et je peux plus me rediriger vers les bonnes pages. il reste sur index.php .



](*,) ca va me rendre dingue :oops: #-o

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 15:12

et je peux plus me rediriger vers les bonnes pages. il reste sur index.php .
C'est à dire ?! pas une redirection ne marche ou apres avoir fait une redirection ?

Montre ton code pour voir comment tu l'a intégré.

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 15:20

le script javascript je l'ai mis entre les balises <head>

Code : Tout sélectionner

<script language="javascript"> function action(NbRadio,chemin) { var m=0; for (i=0;i<=NbRadio;i++) { if (document.forms.modif.id_produit[i].checked==true) { m=document.forms.modif.id_produit[i].value; break; } } window.location.replace(chemin+"?id="+m); } </script>
apres mond code ca donne ceci:
<form name="rech" method="post" action="">
  <table width="100%" >
    <tr>
      <td width="8%" rowspan="2"><strong>N&deg; Produit: </strong></td>
      <td width="20%" rowspan="2"><input type="text" name="rech_num"></td>
      <td width="12%" rowspan="2"><div align="left"><strong>ou D&eacute;signation </strong></div></td>
      <td width="20%" rowspan="2"><input type="text" name="rech_des"></td>
      <td width="18%"><div align="right"><strong>tri&eacute; par N&deg; </strong></div></td>
      <td width="22%"><input checked type="radio" name="tri" value="2"></td>
    </tr>
    <tr>
      <td><div align="right"><strong>tri&eacute; par D&eacute;signation</strong></div></td>
      <td><input type="radio" name="tri" value="4"></td>
    </tr>
    <tr>
      <td colspan="6"><input type="submit" name="Submit" value="Rechercher"></td>
    </tr>
  </table>
</form>
<p><u><strong>Listing des Produits: </strong></u></p>
<form name="modif" method="post" action="modifier.php">
  <table width="100%" border="1" cellspacing="0" >
    <tr>
      <td width="5%"><div align="center">&nbsp;</div></td>
      <td width="5%"><div align="center"><strong>N&deg;</strong></div></td>
      <td width="19%"><div align="center"><strong>D&eacute;signation</strong></div></td>
      <td width="26%"><div align="center"><strong>Type de produit </strong></div></td>
      <td width="17%"><div align="center"><strong>Prix</strong></div></td>
      <td width="12%"><div align="center"><strong>Nbr en stock </strong></div></td>
      <td width="16%"><div align="center"><strong>Nbr Min </strong></div></td>
    </tr>
    <?php
	$i = 0;
	while ($data = mysql_fetch_assoc($req_init)) {
		if (fmod($i, 2) <> 0) {
			$BkColor="EEEEEE";
		}
		else {
			$BkColor="FFFFFF";
		} 
		if ($data['produit_nbr_stock'] <= $data['produit_stock_min']) { ?>
			<tr style="color:#FF0000" bgcolor="<?php echo $BkColor;?>">
			  <td><div align="center">
				  <input type="radio" name="id_produit" value="<?php echo $data['produit_id']?>"></div></td>
			  <td><div align="center"><?php echo $data['produit_num']?></div></td>
			  <td><div align="center"><?php echo $data['produit_designation']?></div></td>
			  <td><div align="center"><?php echo $data['type_produit_nom']?></div></td>
			  <td><div align="center"><?php echo $data['produit_prix']?></div></td>
			  <td><div align="center"><?php echo $data['produit_nbr_stock']?></div></td>
			  <td><div align="center"><?php echo $data['produit_stock_min']?></div></td>
			</tr>
	<?php }
		else { ?>
			<tr style="color:#000000" bgcolor="<?php echo $BkColor;?>">
			  <td><div align="center">
				  <input type="radio" name="id_produit" value="<?php echo $data['produit_id']?>"></div></td>
			  <td><div align="center"><?php echo $data['produit_num']?></div></td>
			  <td><div align="center"><?php echo $data['produit_designation']?></div></td>
			  <td><div align="center"><?php echo $data['type_produit_nom']?></div></td>
			  <td><div align="center"><?php echo $data['produit_prix']?></div></td>
			  <td><div align="center"><?php echo $data['produit_nbr_stock']?></div></td>
			  <td><div align="center"><?php echo $data['produit_stock_min']?></div></td>
			</tr>
	<?php }?>
	<?php
	$i++;
	}
	?>
  </table>
   
  <table width="100%" >
  <tr>
    <td width="9%">
      <div align="right">
        <input type="button" onclick="document.location='nouveau.php'" value="Nouveau">
      </div></td>
    <td width="9%"><div align="center">
      <input type="button" onClick="action('<? echo $i; ?>','modifier.php')" value="Modifier">
	  </div></td>
    <td width="20%"><input type="button" onclick="document.location='imprimer.php'" value="Imprimer"></td>
	<td width="26%">
		<input type="button" onClick="action('<? echo $i; ?>','entree.php')" value="Entrées"> 	
	</td>
	<td width="36%"><div align="right">
      <input type="button" onclick="document.location='type/index.php'" value="Type produit">
    </div></td>
  </tr>
</table>
</form>
ya bcp de code a cause de l'affichage.... desole

encore merci pour ton aide c'est simpa :pouce:

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 15:23

tu as changé le nom ,de ton formulaire en cours de route :wink:

Dans le javascript "modif" remplace par "rech"

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 15:29

tu as changé le nom ,de ton formulaire en cours de route :wink:

Dans le javascript "modif" remplace par "rech"
j'ai change rech dans le javascript mais ca marche tjrs pas. tjrs l'erreur comme quoi le code n'est pas supporter

Code : Tout sélectionner

<?php include ('../../lib/connexBDD.lib.php');?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>STOCK CUISINE - CUISINE - PRODUIT</title> <style type="text/css"> <!-- body { background-color: #EBEBEB; } .Style1 {font-weight: bold} --> </style> <script language="javascript"> function action(NbRadio,chemin) { var m=0; for (i=0;i<=NbRadio;i++) { if (document.forms.rech.id_produit[i].checked==true) { m=document.forms.rech.id_produit[i].value; break; } } window.location.replace(chemin+"?id="+m); } </script> </head> <body> <div align="center"><img src="../../img/logo/Tag_av_c.jpg" width="140" height="100"> </div> <?php include("../../default.php");?> <a href="../../index.php"><em>Retour &agrave; l'acceuil</em></a> <br> <?php //initialisaiton: $rech_num = ''; if (!empty($_POST['rech_num'])) $rech_num = $_POST['rech_num']; $rech_des = ''; if (!empty($_POST['rech_des'])) $rech_des = $_POST['rech_des']; echo $rech_num.'<br>'; echo $rech_des.'<br>'; // recherche de tous les produits pour affichage: if ( (empty($_POST['rech_num'])) && (empty($_POST['rech_des'])) ) { $sql_init = "select produit_id, produit_num, type_produit_nom, produit_designation, produit_prix, produit_nbr_stock, produit_stock_min, (produit_nbr_stock - produit_stock_min) as stock_diff from produit, type_produit where produit.type_produit_id = type_produit.type_produit_id and produit_actif = 1 order by stock_diff"; $req_init = mysql_query($sql_init) or die('Erreur SQL !<br>'.$sql_init.'<br>'.mysql_error()); } else { //recherche avec n° avec tri if (!empty($_POST['rech_num'])) { $sql_init = "select produit_id, produit_num, type_produit_nom, produit_designation, produit_prix, produit_nbr_stock, produit_stock_min, (produit_nbr_stock - produit_stock_min) as stock_diff from produit, type_produit where produit.type_produit_id = type_produit.type_produit_id and produit_actif = 1 and produit_num like '".$rech_num.'%'."' order by stock_diff"; $req_init = mysql_query($sql_init) or die('Erreur SQL !<br>'.$sql_init.'<br>'.mysql_error()); } //recherrche avec designation avec tri if (!empty($_POST['rech_des'])) { $sql_init = "select produit_id, produit_num, type_produit_nom, produit_designation, produit_prix, produit_nbr_stock, produit_stock_min, (produit_nbr_stock - produit_stock_min) as stock_diff from produit, type_produit where produit.type_produit_id = type_produit.type_produit_id and produit_actif = 1 and produit_designation like '".$rech_des.'%'."' order by stock_diff"; $req_init = mysql_query($sql_init) or die('Erreur SQL !<br>'.$sql_init.'<br>'.mysql_error()); } } ?> <p><u><strong>Recherche d'un produit:</strong></u></p> <form name="rech" method="post" action=""> <table width="100%" > <tr> <td width="8%" rowspan="2"><strong>N&deg; Produit: </strong></td> <td width="20%" rowspan="2"><input type="text" name="rech_num"></td> <td width="12%" rowspan="2"><div align="left"><strong>ou D&eacute;signation </strong></div></td> <td width="20%" rowspan="2"><input type="text" name="rech_des"></td> <td width="18%"><div align="right"><strong>tri&eacute; par N&deg; </strong></div></td> <td width="22%"><input checked type="radio" name="tri" value="2"></td> </tr> <tr> <td><div align="right"><strong>tri&eacute; par D&eacute;signation</strong></div></td> <td><input type="radio" name="tri" value="4"></td> </tr> <tr> <td colspan="6"><input type="submit" name="Submit" value="Rechercher"></td> </tr> </table> </form> <p><u><strong>Listing des Produits: </strong></u></p> <form name="modif" method="post" action="modifier.php"> <table width="100%" border="1" cellspacing="0" > <tr> <td width="5%"><div align="center">&nbsp;</div></td> <td width="5%"><div align="center"><strong>N&deg;</strong></div></td> <td width="19%"><div align="center"><strong>D&eacute;signation</strong></div></td> <td width="26%"><div align="center"><strong>Type de produit </strong></div></td> <td width="17%"><div align="center"><strong>Prix</strong></div></td> <td width="12%"><div align="center"><strong>Nbr en stock </strong></div></td> <td width="16%"><div align="center"><strong>Nbr Min </strong></div></td> </tr> <?php $i = 0; while ($data = mysql_fetch_assoc($req_init)) { if (fmod($i, 2) <> 0) { $BkColor="EEEEEE"; } else { $BkColor="FFFFFF"; } if ($data['produit_nbr_stock'] <= $data['produit_stock_min']) { ?> <tr style="color:#FF0000" bgcolor="<?php echo $BkColor;?>"> <td><div align="center"> <input type="radio" name="id_produit" value="<?php echo $data['produit_id']?>"></div></td> <td><div align="center"><?php echo $data['produit_num']?></div></td> <td><div align="center"><?php echo $data['produit_designation']?></div></td> <td><div align="center"><?php echo $data['type_produit_nom']?></div></td> <td><div align="center"><?php echo $data['produit_prix']?></div></td> <td><div align="center"><?php echo $data['produit_nbr_stock']?></div></td> <td><div align="center"><?php echo $data['produit_stock_min']?></div></td> </tr> <?php } else { ?> <tr style="color:#000000" bgcolor="<?php echo $BkColor;?>"> <td><div align="center"> <input type="radio" name="id_produit" value="<?php echo $data['produit_id']?>"></div></td> <td><div align="center"><?php echo $data['produit_num']?></div></td> <td><div align="center"><?php echo $data['produit_designation']?></div></td> <td><div align="center"><?php echo $data['type_produit_nom']?></div></td> <td><div align="center"><?php echo $data['produit_prix']?></div></td> <td><div align="center"><?php echo $data['produit_nbr_stock']?></div></td> <td><div align="center"><?php echo $data['produit_stock_min']?></div></td> </tr> <?php }?> <?php $i++; } ?> </table> <table width="100%" > <tr> <td width="9%"> <div align="right"> <input type="button" onclick="document.location='nouveau.php'" value="Nouveau"> </div></td> <td width="9%"><div align="center"> <input type="button" onClick="action('<? echo $i; ?>','modifier.php')" value="Modifier"> </div></td> <td width="20%"><input type="button" onclick="document.location='imprimer.php'" value="Imprimer"></td> <td width="26%"> <input type="button" onClick="action('<? echo $i; ?>','entree.php')" value="Entrées"> </td> <td width="36%"><div align="right"> <input type="button" onclick="document.location='type/index.php'" value="Type produit"> </div></td> </tr> </table> </form> <p></p> <p></p> </body> </html>
c'est peut etre a cause de ma recherche??? mais en tout cas elle marche elle :wink:

voici tout mon code.. et la redirection sur les pages modifier.php et entree.php ne fonctionne pas... je reste sur index.php

chui vraiement pas douer cesj ours ci :(

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 15:37

ah, dsl je viens de voir que tu as 2 formulaires.. celui o`\u il y a les boutons radio s'appel "modif" donc remet dans le javascript "modif" a la place de "rech" comma avant.

ajoute un test visuel dans le javascript (avant le replace)
alert ("i="+NbRadio+" chemin="+chemin);
verifi les donnée, et assure toi de mettre le bon chemin

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 15:47

j'ai les yeux qui commencent a fatiguer :lol:

mais bon j'ai tjrs cette erreur. quand je double click sur l'icone en bas a gauche j'ai une fenetre qui s'ouvre et ya ca dedant:

Image

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 16:01

Encore de ma faut, j'ai fait des test chez moi mais avec un nom de foction différent. "action" est bien evidement un mot réservé

:arrow: change le nom de la fonction en "redirection" ou autre :D

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 16:06

merci bcppour ta patience !!!

pour l'instant ca se redirige et avec l'id.


MERCI BCP

:agenouille:

you are the best :pouce:

soulagement de ma part car je commencais a desesperer

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 16:09

soulagement de ma part car je commencais a desesperer
Il ne faut jamais desesperer, il y a toujours une solution le plus souvent évident meme) :)

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 16:15

ouais d'ailleur j'aime bien ta phrase de signature :lol:

c'etait totalement mon cas....

merci encore

Modérateur PHPfrance
Modérateur PHPfrance | 7636 Messages

22 sept. 2005, 16:20

oui presque, en majuscules -> $_GET['id']

N'oubli pas de mettre [Resolu] :wink:

/!\ Avant de poster se documenter et rechercher.
Qui ne sait pas rendre un service n'a pas le droit d'en demander.
MaBrute

Eléphant du PHP | 181 Messages

22 sept. 2005, 16:21

oui presque, en majuscules -> $_GET['id']

N'oubli pas de mettre [Resolu] :wink:
non j'ai reussi c'est mes yeux ki fatigue et j'avias encore de $_POST[] dans mes pagwes modifier et entree :oops:

la fatigue et le cervo qui bouillonne.


merci encore!!!! :D

Eléphant du PHP | 181 Messages

28 sept. 2005, 11:16

Salut, en effet il s'agit plus d javascript (comme tu l'a dis), alors voila ce que je te propose:
le javascript:
<script language="javascript">
function action(NbRadio,chemin)
{	
  var m=0;
  for (i=0;i<=NbRadio;i++) 
  {
    if (document.forms.modif.id_produit[i].checked==true) 
	{
      m=document.forms.modif.id_produit[i].value;      
      break;
    }
  } 	
	window.location.replace(chemin+"?id="+m);
}
</script>	
Dans le formulaire:
<input type="button" onClick="action('<? echo $i; ?>','entree.php')" value="Entrées">
<input type="button" onClick="action('<? echo $i; ?>','modifier.php')" value="Modifier">
et ensuite tu récupere "l'id" grace a $_GET[id'].
j'ai un probleme avec ce code...

quand il n'y a qu'un enregistrement il refuse de faire le javascript et me dit qu'il y a une erreur....

quand il y a plusieur enregistrement ya pas de soucy.

comme mon niveau en javascript est <= 0 je m'en remet a vous...

d'ou peut venir cette erreur??

merci bcp
-------------------------------------------------------------
d'ailleur une autre petite question qui est en rapport.??

sur cette page j'ai 2 boutons.... un qui confirme la commande et un qui supprime des elements de la commandes (pour si il y a eu erreur de saisie).

mon 1er bonton doit envoyer un formulaire a une page verif.php
mon 2eme envoie l'id du produit selectionner a une page nouveau_supprime.php

comment gerer mon 1er bouton car je suis obliger d'envoyer mes donnee du formulaire a la page verif.php.... si je fais un bonton submit avec dans la balis <form> l'action verif.php.... ben c'est mon 2eme bouton qui marhce pas....

et si je fais pas de sumit ben mes valeurs ne sont pas envoyees a verif.php

comment puisje proceder??? si qqn a vcompris ce que je voulais expliquer :roll: