Rechercher : dans
Par :

Ajout d'une élément dans un tableau PHP

Dernière réponse le 31 jan 2007 à 09:22:01 Mikius_92, le 26 jan 2007 à 13:42:22 
 Signaler ce message aux modérateurs

Mon idée c’est quand que je sélectionne Oui en cliquant sur le bouton Valider

Il faut que le fonction ajoute le chiffre 1 dans le champs Qté de la boucle For.

Et si je sélectionne Non alors le chiffre 0 s’affiche dans le champs Qté.



Voici mon code :



$strCmd .= "<script language = 'Javascript'>";

$strCmd .= "function choix(bouton){";

$strCmd .= "if (bouton.checked)";

$strCmd .= "{";

$strCmd .= "alert(bouton.value)";

$strCmd .= "}";

$strCmd .= "}";

$strCmd .= "</script>";



$strCmd .= "<td align='center' class='affich'>\n";

$strCmd .= "<form >";

$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this)'> Oui<br>";

$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this)'> Non<br>";

$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>";

$strCmd .= "</form>";

$strCmd .= "</td>\n";



J’effectue cette opération où dans la fonction.

Merci.

Configuration: Windows XP
Firefox 2.0.0.1

Meilleures réponses pour « Ajout d'une élément dans un tableau PHP » dans :
Trier un tableau sans utiliser la fonction sort VoirTrier un tableau sans utiliser la fonction sort D'abord on initialise une variable $max avec la 1ère valeur de tableau. Ensuite on va faire une boucle tant que le tableau contient encore des éléments. C'est avec la fonction splice qui a le rôle...
Inverser les éléments d'un tableau -Récursivité- VoirVoici une procédure récursive qui permet d’inverser les éléments d’une partie d’un tableau compris entre la position p et n : Procedure Inverser (Var t : Tab; p, n : Integer); Var aux : Real; Begin If p < n Then ...
Décaler les éléments d'un tableau (Rotation) -Récursivité- VoirVoici une procédure récursive qui permet de décaler tous les éléments d’un tableau d’une position à droite à partir de la position p Procedure Decaler (Var t : Tab; p, n : integer); Begin If p
PHP - Les fichiers VoirLa gestion des fichiers avec PHP Avec PHP, la création ou la lecture de fichiers est, une fois de plus, assez simple. Il existe une multitude de fonctions dédiées à l'utilisation des fichiers. La communication entre le script PHP et le fichier...
Javascript - l'objet Array VoirLes particularités de l'objet Array L'objet Array est un objet du noyau Javascript permettant de créer et de manipuler des tableaux. Voici la syntaxe à utiliser pour créer une variable tableau : var x = new Array(element1[, element2, ...]); Si...
PHP - Récupération de données VoirPHP rend très simple la récupération de données envoyées par l'intermédiaire de formulaires HTML. Création d'un formulaire Grâce à la balise FORM du langage HTML, il est très simple de créer des formulaires comprenant : des champs de saisie des...

1

kij_82, le 26 jan 2007 à 13:55:24

Tu ne peux pas être plus 'précis' quand tu dis :

dans le champs Qté de la boucle For


C'est quoi Qté ? Un champ caché que tu veux dans ton formulaire ?
Boucle For, t'entends quoi par là, où as tu une boucle for ?

Bon, si c'est la première chose que tu veux faire, c'est à dire mettre à jour la valeur d'un champ caché qui sera passé à ton formulaire alors voici la modification :


$strCmd .= "<script language = 'Javascript'>"; 

$strCmd .= "function choix(bouton){"; 

$strCmd .= "if (bouton.checked)"; 

$strCmd .= "{"; 

$strCmd .= "if (bouton.value == "Oui" ){ document.getElementById('Qte').value = 1;}else{document.getElementById('Qte').value = 0;}";

$strCmd .= "}"; 

$strCmd .= "}"; 

$strCmd .= "</script>"; 



$strCmd .= "<td align='center' class='affich'>\n"; 

$strCmd .= "<form >"; 

$strCmd .= "<input type="hidden" name="Qte" id="Qte" value="0" >"; 

$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this)'> Oui<br>"; 

$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this)'> Non<br>"; 

$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>"; 

$strCmd .= "</form>"; 

$strCmd .= "</td>\n"; 




Mais à quoi ca te sert de mettre le code de ta page dans "$strCmd " au juste ? ~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

2

Mikius_92, le 26 jan 2007 à 13:59:26

Non c'est pas un champs caché je veux mettre à jour le champs Qté (Quantité) de mon tableau à jour en fonction de mes boutons radios

$strCmd c'est la variable php où je crée mon tableau etc....

Répondre à Mikius_92

3

kij_82, le 26 jan 2007 à 14:02:18

de mon tableau 

Et il est ou ce fameux tableau ? Tu as autre chose comme code qui pourrait nous être utile pour comprendre ?
~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

4

Mikius_92, le 26 jan 2007 à 14:03:49

Ok le voici

//Affichage des pièces
$strCmd="<br>
<table class='boxtitle' width='100%' border='1' BORDERCOLOR='#000000' bgcolor='white' cellpadding='0' cellspacing='0'>\n";
If ($_SESSION['entreprise_active']!= 'BMA')
{
$strCmd.="<tr>\n
<td>PIECES INTERVENTION</td>\n
<td><img src=\"../../images/changer.jpg\" height=\"22\" border=\"0\" onclick=\"popup_pieces('$numaffaire','$nomdo')\" alt=\"\" title=\"Gestion des pièces\" onmouseover=\"this.style.cursor='hand'\" width=\"22\" /></td>
</tr>\n";
}
$strCmd.=" <tr> \n
<td width='1%' align='center'>Fournisseur</td>\n
<td width='1%' align='center'>Référence</td>\n
<td width='1%' align='center'>Désignation</td>\n
<td width='1%' align='center'>Type Stock</td>\n
<td width='1%' align='center'>Qté Cde</td>\n
<td width='1%' align='center'>Qté</td>\n
<td width='1%' align='center'>Conso</td>\n
<td width='1%' align='center'>Date Conso</td>\n
<td width='1%' align='center'>N° Cde</td>\n
<td width='1%' align='center'>Express</td>\n
<td width='1%' align='center'>Date Cde</td>\n
<td width='1%' align='center'>Date Liv</td>\n
<td width='1%' align='center'>Agence Cde</td>\n
</tr>\n";

for ($i=0;$i<$Nbpieces;$i++)
{

$strCmd .= "<tr>";
$strCmd .= "<td align='center' class='affich'>\n";

if ($Tabpieces[$i]['sst_libelle'] == "STOCK CENTRAL")
{
$strCmd .= "Call Center";
}
else
{
$strCmd .= Ucwords(strtolower($Tabpieces[$i]['nom_cf']));
}
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['reference'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['designation'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['sst_libelle'];
$strCmd .= "</td>";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['qte_cdee'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['qte'];
$strCmd .= "</td>\n";

$strCmd .= "<script language = 'Javascript'>";
$strCmd .= "function choix(bouton){";
$strCmd .= "if (bouton.checked)";
$strCmd .= "{";
$strCmd .= "if (bouton.value == "Oui" ){document.getElementById('Qte').value = 1;}";
$strCmd .= "else{document.getElementById('Qte').value = 0;}";
$strCmd .= "}";
$strCmd .= "}";
$strCmd .= "</script>";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= "<form >";
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this)'> Oui<br>";
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this)'> Non<br>";
$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>";
$strCmd .= "</form>";
$strCmd .= "</td>\n";

/*$strCmd .= "<script language = 'Javascript'>";
$strCmd .= "function choix(bouton){";
$strCmd .= "alert(bouton.value)";
$strCmd .= "}";
$strCmd .= "</script>";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= "<form name='formulaire_".$i."'>";
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui'> Oui<br>";
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non'> Non<br>";
$strCmd .= "<input type='button' value='valider' name='valider_".$i."' onclick= 'choix(formulaire_".$i.".choix_".$i.")'>";
$strCmd .= "</form>";
$strCmd .= "</td>\n";*/

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['datepieceenvoi'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['num_cde'];
$strCmd .= "</td>\n";


$strCmd .= "<td align='center' class='affich'>\n";
if ($Tabpieces[$i]['express'] == 1)
{
$strCmd .= "X";
}
else
{
$strCmd .= "";
}
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['datecde'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['datelivr'];
$strCmd .= "</td>\n";

$strCmd .= "<td align='center' class='affich'>\n";
$strCmd .= $Tabpieces[$i]['sst_libelle'];
$strCmd .= "</td>\n";

}
$strCmd .="</table>";

echo $strCmd;
?>

Répondre à Mikius_92

5

kij_82, le 26 jan 2007 à 14:08:14

Code corrigé :

//Affichage des pièces 
$strCmd="<br> 
<table class='boxtitle' width='100%' border='1' BORDERCOLOR='#000000' bgcolor='white' cellpadding='0' cellspacing='0'>\n"; 
If ($_SESSION['entreprise_active']!= 'BMA') 
{ 
$strCmd.="<tr>\n 
<td>PIECES INTERVENTION</td>\n 
<td><img src=\"../../images/changer.jpg\" height=\"22\" border=\"0\" onclick=\"popup_pieces('$numaffaire','$nomdo')\" alt=\"\" title=\"Gestion des pièces\" onmouseover=\"this.style.cursor='hand'\" width=\"22\" /></td> 
</tr>\n"; 
} 
$strCmd.=" <tr> \n 
<td width='1%' align='center'>Fournisseur</td>\n 
<td width='1%' align='center'>Référence</td>\n 
<td width='1%' align='center'>Désignation</td>\n 
<td width='1%' align='center'>Type Stock</td>\n 
<td width='1%' align='center'>Qté Cde</td>\n 
<td width='1%' align='center'><div id="Qte">Qté</div></td>\n 
<td width='1%' align='center'>Conso</td>\n 
<td width='1%' align='center'>Date Conso</td>\n 
<td width='1%' align='center'>N° Cde</td>\n 
<td width='1%' align='center'>Express</td>\n 
<td width='1%' align='center'>Date Cde</td>\n 
<td width='1%' align='center'>Date Liv</td>\n 
<td width='1%' align='center'>Agence Cde</td>\n 
</tr>\n"; 

for ($i=0;$i<$Nbpieces;$i++) 
{ 

$strCmd .= "<tr>"; 
$strCmd .= "<td align='center' class='affich'>\n"; 

if ($Tabpieces[$i]['sst_libelle'] == "STOCK CENTRAL") 
{ 
$strCmd .= "Call Center"; 
} 
else 
{ 
$strCmd .= Ucwords(strtolower($Tabpieces[$i]['nom_cf'])); 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['reference']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['designation']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte_cdee']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "if (bouton.checked)"; 
$strCmd .= "{"; 
$strCmd .= "if (bouton.value == "Oui" ){document.getElementById('Qte').value = 1;}"; 
$strCmd .= "else{document.getElementById('Qte').value = 0;}"; 
$strCmd .= "}"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form >"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this)'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this)'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n"; 

/*$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "alert(bouton.value)"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form name='formulaire_".$i."'>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider_".$i."' onclick= 'choix(formulaire_".$i.".choix_".$i.")'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n";*/ 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datepieceenvoi']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['num_cde']; 
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
if ($Tabpieces[$i]['express'] == 1) 
{ 
$strCmd .= "X"; 
} 
else 
{ 
$strCmd .= ""; 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datecde']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datelivr']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>\n"; 

} 
$strCmd .="</table>"; 

echo $strCmd; 
?>


Je me permet de ré-itérer ma question, à quoi cela te sert-il de mettre le code de ta page dans une variable et de l'afficher ensuite ?
Ce ne serait pas plus clair et lisible de mettre directement le code ?
~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

6

Mikius_92, le 26 jan 2007 à 14:15:19

Ben en faite, c'était comme ca lorsque j'ai reprise le logiciel de ma boite et j'dois juste rajouter ou optimiser le code du logiciel donc bref je sais qu'ils auraient pu mettre le code directement mais bon d'aprés eux, c'est plus simple comme ca.

Et pour mon problème ?

Répondre à Mikius_92

7

kij_82, le 26 jan 2007 à 14:26:33

Haa, excuse moi ^^

Voici voilà :

//Affichage des pièces 
$strCmd="<br> 
<table class='boxtitle' width='100%' border='1' BORDERCOLOR='#000000' bgcolor='white' cellpadding='0' cellspacing='0'>\n"; 
If ($_SESSION['entreprise_active']!= 'BMA') 
{ 
$strCmd.="<tr>\n 
<td>PIECES INTERVENTION</td>\n 
<td><img src=\"../../images/changer.jpg\" height=\"22\" border=\"0\" onclick=\"popup_pieces('$numaffaire','$nomdo')\" alt=\"\" title=\"Gestion des pièces\" onmouseover=\"this.style.cursor='hand'\" width=\"22\" /></td> 
</tr>\n"; 
} 
$strCmd.=" <tr> \n 
<td width='1%' align='center'>Fournisseur</td>\n 
<td width='1%' align='center'>Référence</td>\n 
<td width='1%' align='center'>Désignation</td>\n 
<td width='1%' align='center'>Type Stock</td>\n 
<td width='1%' align='center'>Qté Cde</td>\n 
<td width='1%' align='center'><div id="Qte">Qté</div></td>\n 
<td width='1%' align='center'>Conso</td>\n 
<td width='1%' align='center'>Date Conso</td>\n 
<td width='1%' align='center'>N° Cde</td>\n 
<td width='1%' align='center'>Express</td>\n 
<td width='1%' align='center'>Date Cde</td>\n 
<td width='1%' align='center'>Date Liv</td>\n 
<td width='1%' align='center'>Agence Cde</td>\n 
</tr>\n"; 

for ($i=0;$i<$Nbpieces;$i++) 
{ 

$strCmd .= "<tr>"; 
$strCmd .= "<td align='center' class='affich'>\n"; 

if ($Tabpieces[$i]['sst_libelle'] == "STOCK CENTRAL") 
{ 
$strCmd .= "Call Center"; 
} 
else 
{ 
$strCmd .= Ucwords(strtolower($Tabpieces[$i]['nom_cf'])); 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['reference']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['designation']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte_cdee']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "if (bouton.checked)"; 
$strCmd .= "{"; 
$strCmd .= "if (bouton.value == "Oui" ){document.getElementById('Qte').innerHTML = '1';}"; 
$strCmd .= "else{document.getElementById('Qte').innerHTML = '0';}"; 
$strCmd .= "}"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form >"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this)'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this)'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n"; 

/*$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "alert(bouton.value)"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form name='formulaire_".$i."'>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider_".$i."' onclick= 'choix(formulaire_".$i.".choix_".$i.")'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n";*/ 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datepieceenvoi']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['num_cde']; 
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
if ($Tabpieces[$i]['express'] == 1) 
{ 
$strCmd .= "X"; 
} 
else 
{ 
$strCmd .= ""; 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datecde']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datelivr']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>\n"; 

} 
$strCmd .="</table>"; 

echo $strCmd; 
?>

~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

8

Mikius_92, le 26 jan 2007 à 14:30:43

Merci beaucoup t'inquiètes pas y a pas d'soucis pour savoir la raison pr le code :p

Répondre à Mikius_92

10

Mikius_92, le 26 jan 2007 à 14:36:54

D'aprés la source lorsque j'exécutes, ca met l'erreur :

'document.getElementById(...)' a la valeur Null ou n'est pas un objet.

Ouais je n'oublierais pas la balise .

Répondre à Mikius_92

11

kij_82, le 26 jan 2007 à 15:03:14

Décidément...

Et ca ca donne quoi ?

<?php

//Affichage des pièces 
$strCmd="<br> 
<table class='boxtitle' width='100%' border='1' BORDERCOLOR='#000000' bgcolor='white' cellpadding='0' cellspacing='0'>\n"; 
If ($_SESSION['entreprise_active']!= 'BMA') 
{ 
$strCmd.="<tr>\n 
<td>PIECES INTERVENTION</td>\n 
<td><img src=\"../../images/changer.jpg\" height=\"22\" border=\"0\" onclick=\"popup_pieces('$numaffaire','$nomdo')\" alt=\"\" title=\"Gestion des pièces\" onmouseover=\"this.style.cursor='hand'\" width=\"22\" /></td> 
</tr>\n"; 
} 
$strCmd.=" <tr> \n 
<td width='1%' align='center'>Fournisseur</td>\n 
<td width='1%' align='center'>Référence</td>\n 
<td width='1%' align='center'>Désignation</td>\n 
<td width='1%' align='center'>Type Stock</td>\n 
<td width='1%' align='center'>Qté Cde</td>\n 
<td width='1%' align='center'>Qté</td>\n 
<td width='1%' align='center'>Conso</td>\n 
<td width='1%' align='center'>Date Conso</td>\n 
<td width='1%' align='center'>N° Cde</td>\n 
<td width='1%' align='center'>Express</td>\n 
<td width='1%' align='center'>Date Cde</td>\n 
<td width='1%' align='center'>Date Liv</td>\n 
<td width='1%' align='center'>Agence Cde</td>\n 
</tr>\n"; 

// --- Ajout de la fonction en dehors de la boucle !
$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton, div, nb){"; 
$strCmd .= "if (bouton.checked)"; 
$strCmd .= "{"; 
$strCmd .= "if (bouton.value == 'Oui' ){var quant = nb+1; document.getElementById(div).innerHTML = quant;}"; 
$strCmd .= "else{document.getElementById(div).innerHTML = '0';}"; 
$strCmd .= "}"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

for ($i=0;$i<$Nbpieces;$i++) 
{ 

$strCmd .= "<tr>"; 
$strCmd .= "<td align='center' class='affich'>\n"; 

if ($Tabpieces[$i]['sst_libelle'] == "STOCK CENTRAL") 
{ 
$strCmd .= "Call Center"; 
} 
else 
{ 
$strCmd .= Ucwords(strtolower($Tabpieces[$i]['nom_cf'])); 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['reference']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['designation']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte_cdee']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n";
$_name_ = "Qte".$i;
$strCmd .= "<div id='"$_name_."'>";
$strCmd .= $Tabpieces[$i]['qte'];
$strCmd .= "</div>";
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form >"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this,'".$_name_."',".$Tabpieces[$i]['qte'].")'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this,'".$_name_."',0)'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n"; 

/*$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "alert(bouton.value)"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form name='formulaire_".$i."'>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider_".$i."' onclick= 'choix(formulaire_".$i.".choix_".$i.")'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n";*/ 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datepieceenvoi']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['num_cde']; 
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
if ($Tabpieces[$i]['express'] == 1) 
{ 
$strCmd .= "X"; 
} 
else 
{ 
$strCmd .= ""; 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datecde']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datelivr']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>\n"; 

} 
$strCmd .="</table>"; 

echo $strCmd; 
?>

~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

12

Mikius_92, le 26 jan 2007 à 15:13:40

Parse error: parse error, unexpected T_VARIABLE in c:\easyphp\www\statscenter\stats\callcenter\techniciens\inte­rvention.php on line 587

$strCmd .= "<td align='center' class='affich'>\n";
$_name_ = "qte".$i;
$strCmd .= "<div id='"$_name_."'>";
$strCmd .= $Tabpieces[$i]['qte'];
$strCmd .= "</div>";
$strCmd .= "</td>\n";

Répondre à Mikius_92

13

kij_82, le 26 jan 2007 à 15:25:48

Bah regarde d'un peu plus pres la ligne et tu verra que j'ai oublié un '.' ;)

Voilà la correction de la ligne :

"<div id='".$_name_."'>"; 
~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

14

Mikius_92, le 26 jan 2007 à 15:31:19

J'ai réussi à exécuter mais rien ne se passe lorsque je cliques sur le bouton Valider et je regardes le fichier source et il m'a dit cette erreur
"erreur de syntaxe"

Répondre à Mikius_92

15

kij_82, le 26 jan 2007 à 15:33:22

Ou est ce qu'il affiche cette erreur de syntaxe ?

Si tu es sous firefox, apres avoir cliqué sur un des bouttons, ouvre la console d'erreur (outil/console d'erreur) et post la ou les erreurs qui sont marquées
~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

16

Mikius_92, le 26 jan 2007 à 15:35:34

Non j'suis sous IE

Répondre à Mikius_92

17

kij_82, le 26 jan 2007 à 15:42:31

Essai avec ca :

<?php

//Affichage des pièces 
$strCmd="<br> 
<table class='boxtitle' width='100%' border='1' BORDERCOLOR='#000000' bgcolor='white' cellpadding='0' cellspacing='0'>\n"; 
If ($_SESSION['entreprise_active']!= 'BMA') 
{ 
$strCmd.="<tr>\n 
<td>PIECES INTERVENTION</td>\n 
<td><img src=\"../../images/changer.jpg\" height=\"22\" border=\"0\" onclick=\"popup_pieces('$numaffaire','$nomdo')\" alt=\"\" title=\"Gestion des pièces\" onmouseover=\"this.style.cursor='hand'\" width=\"22\" /></td> 
</tr>\n"; 
} 
$strCmd.=" <tr> \n 
<td width='1%' align='center'>Fournisseur</td>\n 
<td width='1%' align='center'>Référence</td>\n 
<td width='1%' align='center'>Désignation</td>\n 
<td width='1%' align='center'>Type Stock</td>\n 
<td width='1%' align='center'>Qté Cde</td>\n 
<td width='1%' align='center'>Qté</td>\n 
<td width='1%' align='center'>Conso</td>\n 
<td width='1%' align='center'>Date Conso</td>\n 
<td width='1%' align='center'>N° Cde</td>\n 
<td width='1%' align='center'>Express</td>\n 
<td width='1%' align='center'>Date Cde</td>\n 
<td width='1%' align='center'>Date Liv</td>\n 
<td width='1%' align='center'>Agence Cde</td>\n 
</tr>\n"; 

// --- Ajout de la fonction en dehors de la boucle !
$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton, div, nb){"; 
$strCmd .= "if (bouton.checked)"; 
$strCmd .= "{"; 
$strCmd .= "if (bouton.value == 'Oui' ){var quant = nb+1; document.getElementById(div).innerHTML = ''+quant+'';}"; 
$strCmd .= "else{document.getElementById(div).innerHTML = '0';}"; 
$strCmd .= "}"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

for ($i=0;$i<$Nbpieces;$i++) 
{ 

$strCmd .= "<tr>"; 
$strCmd .= "<td align='center' class='affich'>\n"; 

if ($Tabpieces[$i]['sst_libelle'] == "STOCK CENTRAL") 
{ 
$strCmd .= "Call Center"; 
} 
else 
{ 
$strCmd .= Ucwords(strtolower($Tabpieces[$i]['nom_cf'])); 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['reference']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['designation']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['qte_cdee']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n";
$_name_ = "Qte".$i;
$strCmd .= "<div id='"$_name_."'>";
$strCmd .= $Tabpieces[$i]['qte'];
$strCmd .= "</div>";
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form >"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui' onchange='choix(this,\"".$_name_."\",".$Tabpieces[$i]['qte'].")'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non' onchange='choix(this,\"".$_name_."\",0)'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider($i)'onclick= 'choix($i)'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n"; 

/*$strCmd .= "<script language = 'Javascript'>"; 
$strCmd .= "function choix(bouton){"; 
$strCmd .= "alert(bouton.value)"; 
$strCmd .= "}"; 
$strCmd .= "</script>"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= "<form name='formulaire_".$i."'>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Oui'> Oui<br>"; 
$strCmd .= "<input type='radio' name='choix_".$i."' value='Non'> Non<br>"; 
$strCmd .= "<input type='button' value='valider' name='valider_".$i."' onclick= 'choix(formulaire_".$i.".choix_".$i.")'>"; 
$strCmd .= "</form>"; 
$strCmd .= "</td>\n";*/ 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datepieceenvoi']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['num_cde']; 
$strCmd .= "</td>\n"; 


$strCmd .= "<td align='center' class='affich'>\n"; 
if ($Tabpieces[$i]['express'] == 1) 
{ 
$strCmd .= "X"; 
} 
else 
{ 
$strCmd .= ""; 
} 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datecde']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['datelivr']; 
$strCmd .= "</td>\n"; 

$strCmd .= "<td align='center' class='affich'>\n"; 
$strCmd .= $Tabpieces[$i]['sst_libelle']; 
$strCmd .= "</td>\n"; 

} 
$strCmd .="</table>"; 

echo $strCmd; 
?>



J'ai encore fais une bourde à un endroit :s

~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

18

Mikius_92, le 26 jan 2007 à 15:49:36

Ha ok désolé
d'aprés la source ca provient de là :

<form ><input type='radio' name='choix_9' value='Oui' onchange='choix(this,'Qté9',1)'> Oui<br><input type='radio' name='choix_9' value='Non' onchange='choix(this,'Qté9',0)'> Non<br><input type='button' value='valider' name='valider(9)'onclick= 'choix(9)'></form></td>

c'est celui que j'ai testé bien sur.

Répondre à Mikius_92

19

kij_82, le 26 jan 2007 à 15:57:46

J'ai mis à jour le code dans le post juste au dessus de ton dernier ;)
~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

9

kij_82, le 26 jan 2007 à 14:35:07

Pense bien à mettre la balise "résolu" si la réponse te satisfait :) ~ iclic @ gauch,iclic,  iclic @ droate, iclic, iclic
             et ya pas de bôg môsieu !    ~

Répondre à kij_82

20

 Mikius_92, le 31 jan 2007 à 09:22:01

Ok merci je vais tester ce que tu as mis dans le dernier post ok désolé de répondre maintenant mais j'suis dans mon entreprise que 3 fois par semaine arf.

Répondre à Mikius_92