Bonjour,
j'ai encore un probléme
J'espére encore une fois que les membres de ce fofo vont venir à mon secours.

J'ai un formulaire XHTML qui permet de choisir un ID et lorsque l'on sauvegarde, par une requete AJAX les différentes infos à propos de cet ID sont cherchées et affichées. Tout marche lorsque l'on choisit un ID et qu'il est saisi dans le input. Mais lorsque l'on spécifie une liste d'ID dans le textarea, les ID sont bien récupérés coté PHP mais impossible avec ces ID d'aller taper les infos dans la base de données.

Code html : 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
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
        [...]
	<script language="javascript">
		function add_condition(){
 
			var genotype = document.getElementById('genotype').value;
			var labID = document.getElementById('labID').value;
			var cgcID = document.getElementById('cgcID').value;
			var strain_list = document.getElementById('strain_list').value;
 
			if (genotype==''){
				Effect.toggle('new_condition', 'slide');
				return false ;
			}
 
			// On va instancier un objet de type Ajax.Request
			new Ajax.Request("../php/add_condition.php?genotype="+genotype+"&labID="+labID+"&cgcID="+cgcID+"&strain_list="+strain_list,
			   	{ asynchronous:true, method: 'get',
 
			   	onSuccess: function(t){ // On a un retour du server (la requete a réussi)
							document.getElementById("strain_added").innerHTML += t.responseText ;
							Effect.Grow($('strain_added').lastChild);
							Effect.toggle('new_condition', 'slide');
							document.getElementById("genotype").value = '' ;
							document.getElementById("labID").value = '' ;
							document.getElementById("cgcID").value = '' ;
 
					},
				onFailure: function(){
			  			alert('Request failed. Contact an admin'); // On affiche une alerte si la requete a échoué   		
					}
			});
		}
</script>
</head>
 
<body>
<form method="POST" action="../php/save_condition.php" name="conditions_form">
 
			<div id="new_condition" style="display:none" >
					<!-- Choose the strain -->
					<p><b>Choose the condition strain</b></p>
 
 
						<b>By strain genotype:</b>
						<input name="genotype" id="genotype" size="70" value="{genotype}"/>
 
 
						<b>By Laboratory ID:</b>
						<input name="labID" id="labID" size="20" value="{labID}" />
 
						<b>By CGC ID:</b>
						<input name="cgcID" id="cgcID" size="20" value="{cgcID}" />
 
						<div>
							<textarea id="strain_list" name="strain_list" cols="60" rows="10"></textarea>
						</div>
 
					<p style="text-align:right"><a href="#" onclick="add_condition();return false;"><img id="submit_condition" src="../images/disk.png" alt="#" title="Save this strain"/></a></p>
 
 
			</div>
</body>
</html>

Code php : 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
 
$genotype = $_GET['genotype'];
$labID = $_GET['labID'];
$cgcID = $_GET['cgcID'];
$strain_list = $_GET['strain_list'];
 
$strain_list = explode(",",$strain_list) ;
		$resultToDisplay = '' ;
 
		// on renvoi l'info
		foreach( $strain_list as  $strain_id ) {
			$resultToDisplay .= display_strain($strain_id,TRUE) ;
			//$resultToDisplay .= $strain_id."<br />" ;
		}
		echo ($resultToDisplay) ;
 
function display_strain($strain_id,$del=FALSE){
 
	global $erreur ;
	include_once "./includes/manage_strain.php" ;
 
	$labID = get_strain_labID($strain_id);
	$cgcID = get_strain_cgcID($strain_id);
	$genotype = get_strain_genotype($strain_id);
 
	$strain_display = "<div class=\"strain_display\">" ;
	$strain_display .= "<input type=\"hidden\" name=\"strain_id[]\" value=\"$strain_id\">" ;
	$strain_display .= "<span title=\"$genotype\">Genotype : <b>".substr($genotype,0,40)."</b></span>" ;
	$strain_display .= "<span style=\"margin-left:20px\">Lab ID : $labID</span>" ;
	$strain_display .= "<span style=\"margin-left:20px\">CGC ID : $cgcID</span><br />" ;
 
	$strain_display .= "</div>" ;
 
 
	return $strain_display ;
 
}

Si je ne fais que faire un echo des strain_id récupérés, ça marche. Donc je me demande si le type de la variable $strain_id n'est pas différente selon qu'elle soit récupérée dans un input ou dans un textarea ... et donc impossible de recuperer les infos dans la BDD avec.

J'ai élagué le code pour plus de clarté mais si vous voulez des infos demander moi.
Help !

Merci