Bonsoir,

j'éssaye depuis plusieurs jour de remplir une liste B en fonction du choix de la liste A mais la liste B ne se remplit pas.

J'aimerais que vous m'expliquiez mon erreur.

voila mon code:

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
        session_start();
        include("./includes/config_admin.php");
        include("./includes/parametres.php");
        include("./includes/fonctions.php");
        include("./includes/connect.php");
        
        $js = CodeJs($liste_page_js,$bdd_host, $bdd_login, $bdd_mdp, $bdd_select);
        $ajax = CodeAjax($liste_page_js,$bdd_host, $bdd_login, $bdd_mdp, $bdd_select);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
        <link href="design.css" rel="stylesheet" type="text/css" />
        <link href="css/slimbox.css" rel="stylesheet" type="text/css" />
		<link href="favicon.gif" rel="icon" type="image/gif" />
 
		<!-- <script type="text/javascript" src="js/slimbox.js"></script> -->
		<script type="text/javascript" src="js/mootools.js"></script>
		<script type="text/javascript">		
		window.addEvent('domready', function(){
			alert('coucou');
			var url = "recup.php";
			var options = { update : $('position'), method : 'get' };
			var exemple2Ajax= new Ajax(url, options);
			$('pere_cat').onchange = function () { exemple2Ajax.request('message='+($('exemple_php_mootools_text').value)); };
		});
		</script>
		<?php //echo $js; ?>
		<?php //echo $ajax; ?>
    </head>
 
    <body>
    	<div>
            <?php
                                //include("header.php");
                        ?>
			<?php
                                //include("barre_menu.php");
                        ?>
            <div id="corps">
              <form method="POST" action="traite_gallery.php" enctype="multipart/form-data">
			<p>
				<label for="titre_cat">Titre : </label>
				<input type="text" name="titre_cat" id="titre_cat" value="" />
				<br />
				<label for="pere_cat">Catégorie principale : </label>
				<select name="pere_cat" style="text-align : left;" id="pere_cat">
					<?php
                                                connect();
                                                $sql = 'SELECT id_cat,nom_cat FROM categorie WHERE pere_cat = 0 ORDER BY position_cat';
                                                
                                                $reponse = mysql_query($sql);
                                                
                                                while($donnees = mysql_fetch_array($reponse))
                                                        {
                                                                echo '<option value="' . $donnees['id_cat'] . '">' . stripslashes($donnees['nom_cat']) . '</option>';
                                                        }
                                        ?>
				</select><br />
				<label for="img_cat">Image : </label>
				<input style="width : 500px;" type="file" name="img_cat" id="img_cat" >
				<br />
				<div id='position' style='display:inline'>
				<label for="position">Position : </label>
					<select name="position">
						<option value='0'>Choisir la position</option>
					</select>
				</div>
				<br />
				<label for="description">Description : </label>
				<br />
				<textarea name="description" id="description"></textarea>
				<br />
				<input type="submit" name="envoi" id="form_envoi" value="Créer" />
			</p>
		</form>
			<div id="fin_corps">
				<!-- /!\ Ne rien écrire ici /!\ -->
			</div>
			<div id="pied">
				<?php
                                        //include("pied.php");
                                ?>
			</div>
        </div>
    </body>
</html>
voila la page php qui récupére l'info pour l'ajax:

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
<?php
        echo "<label for='position'>Position:</label";
        echo "<select name='position'>";
        if(isset($_POST['pere_cat'])){
                if($_POST['pere_cat'] != "-1"){
                        mysql_connect("localhost","root","mysql");
                        mysql_select_db("semit");
                        $res = mysql_query("SELECT COUNT(id_cat) as nb FROM categorie WHERE pere_cat=".$_POST["pere_cat"]." ORDER BY position_cat DESC LIMIT 0,1");
                        $result=mysql_fetch_array($res);
                        $nb=$result['nb'];
                        $nb += 1;
                        
                        for($i=1;$i<=$nb;$i++)
                        {
                                echo "<option value='".$i."'>".$i."</option>";
                        }
                }
                else{
                        echo "<option value='-1'>Choisir la position</option>";
                }
        }
        echo "</select>";
?>
je vous remercie d'avance pour vos réponses.

bonne soirée