no save
Assistance
Achat
News

Forum | webmastering
[PHP-HTML] checkbox cochée ou non ?
Yotte, le mar. 16 août 2005 à 11:17:20
Bonjour,

j'ai cherché en vain une réponse à ma question sur ce forum.
Voilà mon problème :

j'ai un formulaire HTML dans une première page :
<form>
<p>Que voulez-vous étudier ?
Cocher les cases utiles.
<table border="2" cellpadding="5">
<tr><th colspan="2"><input type="checkbox" name="choix[]" value="a"><a href="a.php">A</a></th></tr>
<tr><th colspan="2"><input type="checkbox" name="choix[]" value="b"><a href="b.php">B</a></th></tr>
<tr><th colspan="2"><input type="checkbox" name="choix[]" value="c"><a href="c.php">C</a></th></tr>
<tr><th width="20%" rowspan="6">autre</th>
<td width="300"><input type="checkbox" name="choix[]" value="d"> <a href="d.php">D</a></td></tr>
<tr><td><input type="checkbox" name="choix[]" value="e"> <a href="e.php">E</a></td></tr>
<tr><td><input type="checkbox" name="choix[]" value="f"> <a href="f.php">F</a></td></tr>
<tr><td><input type="checkbox" name="choix[]" value="g"> <a href="g.php">G</a></td></tr>
<tr><td><input type="checkbox" name="choix[]" value="h"> <a href="h.php">H</a></td></tr>
<tr><td><input type="checkbox" name="choix[]" value="i"> <a href="i.php">I</a></td></tr>
</table>
</div>
</form>


Dans une deuxième page, je voudrai pouvoir utiliser le fait que les checkbox soient cochées ou non (sans utiliser Javascript puisque je n'ai plus de formulaire dans ma 2ème page). J'ai déjà essayé d'afficher ce qui était coché, en vain :
<? if(isset($_POST['choix']))
{$_SESSION['choix']=$_POST['choix'];}
else{$_SESSION['choix']=' ';}

echo 'Vous avez choisi d\'étudier : ';
for ($i=0; $i<sizeof($_SESSION['choix']); $i++)
{if ($_SESSION['choix'] == '')
{echo '';}
else
{echo $_SESSION['choix'][$i].'<br>';}
}
?>

y'a-t-il un moyen de savoir si une case est cochée, un truc du genre if ($_SESSION['choix'][$i] == 'checked') ?

Merci de votre aide !


StreM
août 05
Suivant
REPONSES
StreM
août 05
emibru
août 07
Nep
août 07
guetteur
avr. 08
Pat
03 janv.
manu
09 janv.
Version Web
Réalisé par RedShift
no save