Garder la sélection d'un select après un clique sur un lien dans un form en method POST
Bonjour,
Le titre parle de lui-même :
Pourquoi ce code met la value du select à -1 à chaque clique sur le lien ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<form method="POST" action="" name="form1" id="form1">
<table id="tab1" name="tab1" cellspacing="10">
<tr>
<th>
Année :
</th>
</tr>
<tr>
<td>
<select id="annee" name="annee" onChange="form1.submit();">
<option value=-1>-- Choisissez --</option>
<?php
if(isset($_POST['annee'])){
$annee=$_POST['annee'];} else{$annee=-1;}
$r3=mssql_query("SELECT distinct annee FROM utilisateur_gldr WHERE etat = 1 OR etat = 3 ORDER BY annee desc");
While($var2=mssql_fetch_assoc($r3))
{
echo "<option value=".$var2["annee"]."";
if($annee==$var2["annee"]) { echo " selected"; }
echo ">".$var2['annee']."</option>\n";
}
?>
</select>
</td>
</tr>
<tr><td><a href="garder_selection_select.php?matric=<?php echo $agent['matric']; ?>">lien</a></td>
</table>
</form> |
Merci pour votre aide :)