Flux rss
Collection CommentÇaMarche.net
Rechercher : dans
Par :

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

Mikius_92, le vendredi 26 janvier 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

1

kij_82, le vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 2007 à 15:35:34

Non j'suis sous IE

Répondre à Mikius_92

17

kij_82, le vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 vendredi 26 janvier 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 mercredi 31 janvier 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
Xml en tableau php (Résolu) Bonjour tout le monde, j'aimerais conventir un fichier xml en tableau php, j'utilise php 4 et domxml si jamais j'aimerais printer mes infos comme cela : $a = array ('a' => 'pomme', 'b' => 'banane', 'c' => 'kiwi'); print_r ($a['c']); le... www.commentcamarche.net/forum/affich-4109153-xml-en-tableau-php
Recupération valeurs tableau php Bonjour , Voilà mon soucis : Je souhaite récupérer les valeurs de mon tableau php mais dans ma page html mais il m'affiche "array" au lieu du texte qui devrait apparaitre et je ne vois pas d'ou le probleme peut venir car l'incrémentation se fait bien.... www.commentcamarche.net/forum/affich-727397-recuperation-valeurs-tableau-php
[PHP/SQL] Supprimer des champs dans 1 tableau Bonjour à ceux qui me liront J'ai débuté PHP il y a quelques semaines et je tente désormais dans une page d'admin d'afficher un tableaux avec toutes les valeurs d'une table, et d'avoir ensuite la possibilité de supprimer l'enregistrement de la table.... www.commentcamarche.net/forum/affich-2272499-php-sql-supprimer-des-champs-dans-1-tableau
Inverser les éléments d'un tableau -Récursivité-Voici 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 ... www.commentcamarche.net/faq/sujet-8811-inverser-les-elements-d-un-tableau-recursivite
Liste simplement chaînéeLISTES SIMPLEMENT CHAINÉES Requis I. INTRODUCTION II. Définition III. La construction du prototype d'un élément de la liste IV. Opérations sur les listes chaînées A. Initialisation B. Insertion d'un élément dans la liste 1. Insertion... www.commentcamarche.net/faq/sujet-7444-liste-simplement-chainee
PHP : foreach et arrayBonjour à tous, J'ai un problème sur un site que je développe en ce moment. j'ai un tableau PHP (array), et une fonction foreach dans laquelle je regarde le stock pour chaque produit dans ma base de données. Les résultats s'affichent bien, tout est... www.commentcamarche.net/forum/affich-3164937-php-foreach-et-array
Taille d'un tableau phpBonjour, je voudrais faire une boucle sur les lignes d'un tableau dont le nombre de colonnes est 4 et les lignes étant dynamiques for ($i=0;$i www.commentcamarche.net/forum/affich-11252734-taille-d-un-tableau-php
PHP - Les variablesConcept de variable avec PHP Une variable est un objet repéré par son nom, pouvant contenir des données, qui pourront être modifiées lors de l'exécution du programme. Les variables en langage PHP peuvent être de trois... www.commentcamarche.net/contents/php/phpvar.php3
PHP - Administration d'un annuaire LDAPIntroduction à LDAP PHP permet la connexion et l'envoi de requêtes sur un annuaire LDAP, c'est-à-dire un serveur permettant de stocker des informations de manière hiérarchique. Pour plus d'informations sur les fonctions LDAP de PHP, reportez... www.commentcamarche.net/contents/php/phpldapadmin.php3
Javascript - Les tableauxIntroduction à la notion de tableau Les variables de Javascript ne permettent de stocker qu'une seule donnée à la fois. Or, étant donné qu'il est souvent utile de manipuler de nombreuses données, le concept de variable se révéle parfois... www.commentcamarche.net/contents/javascript/jstab.php3