J ai un formulaire dans lequel j ai un tableau .Et dans ce tableau j ai pour chaque ligne un bouton option dans lequel je stocke un identifiant.
Et donc à chaque clique sur une ligne du tableau je selectionne le bouton identifiant correspondant.
Sur mon formulaire j ai des liste deroulante et lorsqu on choisi un element de la liste sa recharge la page et donc en theorie sa devrais aussi m afficher la valeur contenu dans le bouton option si je fais fait un echo de celui :
mais la je n ai rien qui s affiche.echo "tableau1 numserie ".$_POST['a'];
????
Voila mon code
<?php
session_start();
?>
<html>
<head>
<style>
.red {background-color:white}
.blue {background-color:blue}
.black{background-color:black}
.tab{cursor:crosshair }
.option{checked:checked}
</style>
<SCRIPT LANGUAGE="JavaScript">
function reDimensionner() {
var lg = screen.width;
var ht = screen.height;
window.resizeTo(lg,ht);
window.moveTo(0,0);
}
var lastTr;
var ids;
function blok(objet, id_objet){
objet.className="option"
if(lastTr)lastTr.className="red"
objet.className="blue"
lastTr=objet;
document.getElementById(id_objet).checked = true;
ids=document.getElementById(id_objet).value;
alert(ids);
}
</script>
</head>
<? if(isset($_GET['poles'])){
$_SESSION['poles']=@$_GET['poles'];
//echo "LA FAMILLE EST = A : ".$_SESSION['fams'];
}
if(isset($_GET['poste'])){
$_SESSION['poste']=@$_GET['poste'];
}
echo "<h2>".$_SESSION['poles']."</h2>";
echo "<h2>".$_SESSION['poste']."</h2>";
if(isset($_GET['poles1'])){
$_SESSION['poles1']=@$_GET['poles1'];
//echo "LA FAMILLE EST = A : ".$_SESSION['fams'];
}
if(isset($_GET['poste1'])){
$_SESSION['poste1']=@$_GET['poste1'];
}
echo "<h2>".$_SESSION['poles1']."</h2>";
echo "<h2>".$_SESSION['poste1']."</h2>";
echo "tableau1 numserie ".$_POST['a'];
?>
<body onLoad="reDimensionner()">
<form name="affecter" method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>">
<? include("connexion.inc.php"); ?>
<br>
<br>
<div style="width:400px; height:110px;overflow:auto;">
<? $sql="select distinct(objet.numserie),etat_objet.numoperation,etat,type_objet,marque,modele from objet,types_etat,etat_objet where etat_objet.numserie=objet.numserie and types_etat.numetat=etat_objet.numetat and etat='En commande' and etat_objet.numoperation=(select max(numoperation) from etat_objet where etat_objet.numserie=objet.numserie) order by etat_objet.numoperation";
$result=pg_query($sql);
?>
<table border="1">
<tr><th style="display:none">a</th>
<th>Etat</th>
<th>Famille</th>
<th>N° serie</th>
<th>Marque</th>
<th>Modele</th>
</tr>
<?
$i=0;
while($list=pg_fetch_array($result)){
?>
<tr class="white" onClick="blok(this, 'radio<? echo $i ; ?>')"><td style="display:none"><input type="radio" name="a" id="radio<? echo $i ; ?>" value="<? echo $list['numserie'];?>"></td>
<td><? echo $list['etat']; ?></td>
<td><? echo $list['type_objet']; ?></td>
<td><? echo $list['numserie']; ?></td>
<td><? echo $list['marque']; ?></td>
<td><? echo $list['modele']; ?></td>
</tr>
<?
$i=$i+1;
}
?>
</table>
</div>
<br>
<br>
<table>
<tr><td>Poles</td><td>
<?
////////////////affichage poles////////////////////
// on crée la requête SQL
$sql = "select numpole,code_pole from poles order by code_pole";
$res=pg_query($sql);
?>
<select name="pol" onChange="location.href='<?php echo $_SERVER['PHP_SELF'] ; ?>?poles=' + this.value">
<option>--Poles--</option>
<?
while($list=pg_fetch_array($res)){
?>
<option value="<?php echo ($list['code_pole']);?>" <? if(@$_SESSION['poles'] == $list['code_pole']){echo(" selected=\"selected\"");}?>><?php echo ($list['code_pole']); ?></option>
<?php
}
?>
</select>
</td>
<td>N°Poste</td><td>
<?
////////////////affichage poste////////////////////
// on crée la requête SQL
if(isset($_GET['poles'])){
$sql = "select numposte,nom_personnel,prenom,pole from poles,poste,personnel where personnel.numpersonnel=poste.numpersonnel and poles.numpole=poste.numpole and code_pole='".$_GET['poles']."' order by nom_personnel";
}else{
$sql = "select numposte,nom_personnel,prenom,pole from poles,poste,personnel where personnel.numpersonnel=poste.numpersonnel and poles.numpole=poste.numpole and code_pole='".@$_SESSION['poles']."' order by nom_personnel";
}
//echo "<b>".$sql."</b>";
$res=pg_query($sql);
?>
<select name="posts" onChange="location.href='<?php echo $_SERVER['PHP_SELF'] ; ?>?poste=' + this.value">
<option>--Poste--</option>
<?
while($list=pg_fetch_array($res)){
?>
<option value="<?php echo ($list['numposte']);?>" <? if(@$_SESSION['poste'] == $list['numposte']){echo(" selected=\"selected\"");}?>><?php echo ($list['nom_personnel']); ?></option>
<?php
}
?>
</select>
</td>
</tr>
</table>
<br>
<div style="width:400px; height:110px;overflow:auto;">
<?
//Affichage des objets detenu par une personne en fonction du choix du poste
if(isset($_GET['poste'])){
$sql1="select distinct(objet.numserie),etat_objet.numoperation,etat,type_objet,marque,modele from objet,types_etat,etat_objet,poste where etat_objet.numserie=objet.numserie and types_etat.numetat=etat_objet.numetat and poste.numposte=objet.numposte and etat='En poste' and objet.numposte='".$_GET['poste']."' and etat_objet.numoperation=(select max(numoperation) from etat_objet where etat_objet.numserie=objet.numserie) order by etat_objet.numoperation";
}else{
$sql1="select distinct(objet.numserie),etat_objet.numoperation,etat,type_objet,marque,modele from objet,types_etat,etat_objet,poste where etat_objet.numserie=objet.numserie and types_etat.numetat=etat_objet.numetat and poste.numposte=objet.numposte and etat='En poste' and objet.numposte='".$_SESSION['poste']."' and etat_objet.numoperation=(select max(numoperation) from etat_objet where etat_objet.numserie=objet.numserie) order by etat_objet.numoperation";
}
$resu=pg_query($sql1);
?>
<table border="1">
<tr><th style="display:none">b</th>
<th>Famille</th>
<th>N°serie</th>
<th>Marque</th>
<th>Modele</th>
<th>Etat</th>
</tr>
<?
$i=0;
while($list1=pg_fetch_array($resu)){
?>
<tr class="white" onClick="blok(this, 'radio2<? echo $i ; ?>')"><td style="display:none"><input type="radio" name="b" id="radio2<? echo $i ; ?>" value="<? echo $list1['numserie'];?>"></td>
<td><? echo $list1['type_objet']; ?></td>
<td><? echo $list1['numserie']; ?></td>
<td><? echo $list1['marque']; ?></td>
<td><? echo $list1['modele']; ?></td>
<td><? echo $list1['etat']; ?></td>
</tr>
<?
$i=$i+1;
}
?>
</table>
</div>
<br>
<br>
<br>
<table>
<tr><td>Poles</td><td>
<?
////////////////affichage poles////////////////////
// on crée la requête SQL
$sql = "select numpole,code_pole from poles order by code_pole";
$res=pg_query($sql);
?>
<select name="pol1" onChange="location.href='<?php echo $_SERVER['PHP_SELF'] ; ?>?poles1=' + this.value">
<option>--Poles--</option>
<?
while($list=pg_fetch_array($res)){
?>
<option value="<?php echo ($list['code_pole']);?>" <? if(@$_SESSION['poles1'] == $list['code_pole']){echo(" selected=\"selected\"");}?>><?php echo ($list['code_pole']); ?></option>
<?php
}
?>
</select>
</td>
<td>N°Poste</td><td>
<?
////////////////affichage poste////////////////////
// on crée la requête SQL
if(isset($_GET['poles1'])){
$sql = "select numposte,nom_personnel,prenom,pole from poles,poste,personnel where personnel.numpersonnel=poste.numpersonnel and poles.numpole=poste.numpole and code_pole='".$_GET['poles1']."' order by nom_personnel";
}else{
$sql = "select numposte,nom_personnel,prenom,pole from poles,poste,personnel where personnel.numpersonnel=poste.numpersonnel and poles.numpole=poste.numpole and code_pole='".@$_SESSION['poles1']."' order by nom_personnel";
}
//echo "<b>".$sql."</b>";
$res=pg_query($sql);
?>
<select name="posts1" onChange="location.href='<?php echo $_SERVER['PHP_SELF'] ; ?>?poste1=' + this.value">
<option>--Poste--</option>
<?
while($list=pg_fetch_array($res)){
?>
<option value="<?php echo ($list['numposte']);?>" <? if(@$_SESSION['poste1'] == $list['numposte']){echo(" selected=\"selected\"");}?>><?php echo ($list['nom_personnel']); ?></option>
<?php
}
?>
</select>
</td>
</tr>
</table>
<br>
<div style="width:400px; height:110px;overflow:auto;">
<?
//Affichage des objets detenu par une personne en fonction du choix du poste
if(isset($_GET['poste1'])){
$sql2="select distinct(objet.numserie),etat_objet.numoperation,etat,type_objet,marque,modele from objet,types_etat,etat_objet,poste where etat_objet.numserie=objet.numserie and types_etat.numetat=etat_objet.numetat and poste.numposte=objet.numposte and etat='En poste' and objet.numposte='".$_GET['poste1']."' and etat_objet.numoperation=(select max(numoperation) from etat_objet where etat_objet.numserie=objet.numserie) order by etat_objet.numoperation";
}else{
$sql2="select distinct(objet.numserie),etat_objet.numoperation,etat,type_objet,marque,modele from objet,types_etat,etat_objet,poste where etat_objet.numserie=objet.numserie and types_etat.numetat=etat_objet.numetat and poste.numposte=objet.numposte and etat='En poste' and objet.numposte='".@$_SESSION['poste1']."' and etat_objet.numoperation=(select max(numoperation) from etat_objet where etat_objet.numserie=objet.numserie) order by etat_objet.numoperation";
}
$resu2=pg_query($sql2);
?>
<table border="1">
<tr><th style="display:none">b</th>
<th>Famille</th>
<th>N°serie</th>
<th>Marque</th>
<th>Modele</th>
<th>Etat</th>
</tr>
<?
$i=0;
while($list2=pg_fetch_array($resu2)){
?>
<tr class="white" onClick="blok(this, 'radio3<? echo $i ; ?>')"><td style="display:none"><input type="radio" name="c" id="radio3<? echo $i ; ?>" value="<? echo $list2['numserie'];?>"></td>
<td><? echo $list2['type_objet']; ?></td>
<td><? echo $list2['numserie']; ?></td>
<td><? echo $list2['marque']; ?></td>
<td><? echo $list2['modele']; ?></td>
<td><? echo $list2['etat']; ?></td>
</tr>
<?
$i=$i+1;
}
?>
</table>
</div>
<br>
</form>
</body>
</html>
Merci