Checkbox selected lors d'un rafraichissement

cedric12 Messages postés 29 Statut Membre -  
 happyrain -
bonjour,

sur mon site l'utilisateur rempli les cases d'un formulaire avec checkbox.
Je souhaite lorsque la nouvelle page apparait que la case reste cochée. Comment faire?

Merci

2 réponses

  1. laurent
     
    Bonjour,

    Tu utilises quoi pour créér ta checkbox ?

    En html si tu mets ca elle doit être toujours cochée:
    type="checkbox" name="Nom" class="menuradio" value="VisuEc" checked
    0
    1. ilhem
       
      commet faire avec java
      0
  2. hbarre
     
    il faudrai faire un script php du genre:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Sans Titre</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="generator" content="HAPedit 3.1">
    </head>
    <body bgcolor="#FFFFFF">
    <hr />
    <form action="toto.php" name="titi" method="post">
    <input type="submit" name="bt_ok" />
    <?

    /* pour 10 chekbox */
    for ($i=0;$i<=9;$i++){
    $etat="";
    $nom="coche" . $i;
    if (isset($_POST[$nom])){
    $valeur=$_POST[$nom];
    if ($valeur=="on"){
    $etat="checked";
    }
    }
    echo "<input type=\"checkbox\" name=\"$nom\" $etat/>Coche $i";
    }

    ?>
    </form>
    </body>
    </html>

    et ça devrai marcher
    0
    1. hbarre
       
      j'ai oublié il faut appeller ta page 'toto.php'
      0
    2. happyrain
       
      c'est pas plutôt => checked="checked" ?
      0