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.

<?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
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.