Bonjour, je m'adresse à vous car çà doit faire 2 heures que je bute sur un problème de récupération de select multiple.

Le code suivant à été récupérer sur le net :
<HEAD></HEAD> :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
<script language="JavaScript" type="text/javascript">
 
function deplacer( liste_depart, liste_arrivee ) {
  for( i = 0; i < liste_depart.options.length; i++ ) {
    if( liste_depart.options[i].selected && liste_depart.options[i] != "" ) {
      o = new Option( liste_depart.options[i].text, liste_depart.options[i].value);
      liste_arrivee.options[liste_arrivee.options.length] = o;
      liste_depart.options[i] = null;
      i = i - 1 ;
    }
    else {
      // alert( "aucun element selectionne" );
    }
  }
}
 
function deplacer_tout( liste_depart, liste_arrivee ) {
  for( i = 0; i < liste_depart.options.length; i++ ) {
    o = new Option( liste_depart.options[i].text, liste_depart.options[i].value);
    liste_arrivee.options[liste_arrivee.options.length] = o;
    liste_depart.options[i] = null;
    i = i - 1 ;
  }
}
 
function deplacer_hautbas( liste, sens ) {
  // init
  var listemax = liste.length - 2;
  var listesel = liste.selectedIndex;
  // debordement
  if( ( listesel < 0 ) || ( listesel < 1 && sens == -1 ) || ( listesel > listemax && sens == 1 ) ) {
    return false;
  }
  // permutation
  tmpopt = new Option( liste.options[listesel+sens].text, liste.options[listesel+sens].value );
  liste.options[listesel+sens].text = liste.options[listesel].text;
  liste.options[listesel+sens].value = liste.options[listesel].value;
  liste.options[listesel+sens].selected = true;
  liste.options[listesel].text = tmpopt.text;
  liste.options[listesel].value = tmpopt.value;
  liste.options[listesel].selected = false;
  return true;
}
 
function soumettre_2listes( liste1, liste2 ) {
  var listelen1 = liste1.length;
  for( i = 0; i < listelen1; i++ ) {
    liste1.options[i].selected = true;
  }
  var listelen2 = liste2.length;
  for( j = 0; j < listelen2; j++ ) {
    liste2.options[j].selected = true;
  }
}
 
function soumettre_1liste( liste ) {
  var listelen = liste.length;
  for( i = 0; i < listelen; i++ ) {
    liste.options[i].selected = true;
  }
}
 
</script>
<BODY></BODY> :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
<form name="export" method="POST" OnSubmit="javascript: soumettre_1liste( document.forms[0].choix );" action="recuperation.php">
 
<table summary="" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <th style="width:  90px;"></th>
    <th style="width: 220px;"></th>
    <th style="width: 150px;"></th>
    <th style="width: 220px;"></th>
    <th style="width:  90px;"></th>
  </tr>
  <tr>
    <td><br /></td>
    <td>Champ(s) disponible(s)<br /></td>
    <td><br /></td>
    <td>Champ(s) sélectionné(s)<br /></td>
    <td><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td rowspan="7">
      <select name="dispo[]" id="dispo" style="width: 210px;" size="16" multiple="multiple" OnDblClick="javascript: deplacer( this.form.dispo, this.form.choix );">
      <?php
        while($data = mysql_fetch_array($result)) {
          echo '<option value="'.$data['geolocalisations_id'].'">'.$data['geolocalisations_libelle'].'<br /></option>';
        }
       ?>
      </select><br />
    </td>
    <td><br /></td>
    <td rowspan="7">
      <select name="choix[]" id="choix" style="width: 210px;" size="16" multiple="multiple" OnDblClick="javascript: deplacer( this.form.choix, this.form.dispo );">
      </select><br />
    </td>
    <td><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><input type="button" value="ajouter >" OnClick="javascript: deplacer( this.form.dispo, this.form.choix );" /><br /></td>
    <td rowspan="2"><input type="button" value="Monter" OnClick="javascript: deplacer_hautbas( this.form.choix, -1 );" /><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><input type="button" value="ajouter tout >>" OnClick="javascript: deplacer_tout( this.form.dispo, this.form.choix );" /><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><br /></td>
    <td><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><input type="button" value="< retirer" OnClick="javascript: deplacer( this.form.choix, this.form.dispo );" /><br /></td>
    <td rowspan="2"><input type="button" value="Descendre" OnClick="javascript: deplacer_hautbas( this.form.choix, 1 );" /><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><input type="button" value="<< retirer tout" OnClick="javascript: deplacer_tout( this.form.choix, this.form.dispo );" /><br /></td>
  </tr>
  <tr>
    <td><br /></td>
    <td><br /></td>
    <td><br /></td>
  </tr>
</table>
<br />
<input type="submit" value="OK" /> <input type="reset" value="Annuler" /><br />
</form>
Et voilà mon code de récupération de la page "recuperation.php" :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
<?php
$id=1;
for ($i = 0, $c = count($_POST['choix']); $i < $c; $i++) {
  $query = "INSERT INTO contenir (graphiques_id, libelledonnees_id) VALUES ('".$id."', '".$_POST['choix'][$i]."');";
  echo $query.'</br>';
  // $result = mysql_query($query);
}
?>
Hors aucune requête ne s'affiche à l'écran.

Je vous remercie d'avance de vos réponses.