Bonjour à tous,

Petit soucis d'édition de variables..

J'ai dans modification.php
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
<script type="text/javascript">
function changement(champ) {
	<?php
	$_SESSION['chgt']['qte'] = false;
	$_SESSION['chgt']['pri'] = false;
	$_SESSION['chgt']['des'] = false;
	$_SESSION['chgt']['date'] = false;
	?>
	alert(champ);
	if(champ == "date") {
		<?php $_SESSION['chgt']['date'] = true; ?>
		alert("<?php echo "Chgt date: ".$_SESSION['chgt']['date']; ?>");
	}
	if(champ == "des") {
		<?php $_SESSION['chgt']['des'] = true; ?>
		alert("<?php echo "Chgt des: ".$_SESSION['chgt']['des']; ?>");
	}
	if(champ == "qte") {
		<?php $_SESSION['chgt']['qte'] = true; ?>
		alert("<?php echo "Chgt qte: ".$_SESSION['chgt']['qte']; ?>");
	}
	if(champ == "pri") {
		<?php $_SESSION['chgt']['pri'] = true; ?>
		alert("<?php echo "Chgt pri: ".$_SESSION['chgt']['pri']; ?>");
	}
}
</script>
 
[...]
 
 
<form action="enregistrerModif.php?modif&id=<?php echo $_GET['id']; ?>" method=POST />
		Date: <input onChange="changement('date');this.value=validation(this.value);" type="text" name="date" value="<?php echo $date; ?>" /><br />
		<input type="hidden" name="clientFinal" id="clientFinal" value=<?php echo $idCA; ?> />
 
		<table style="border-style:dotted; border-color:#3C4E58;">
		<tbody id="cadre">
			<tr style="border-style:dotted; border-color:#3C4E58;">
			 <td style="width:65%; text-align: center;"><strong>Désignation</strong></td>
			 <td style="width:17%; text-align: center;"><strong>Quantité</strong></td>
			 <td style="width:18%; text-align: center;"><strong>Prix/U (HT)</strong></td>
			</tr><?php
			$i = 0;
			while($i < $countProduits-1) {
				echo '<tr style="border-color:#3C4E58;">';
				 echo "<td><input type='text' id='des".$i."' name='des".$i."' style='width: 95%;' onChange=\"changement('des');\" value=".$facture['des'][$i]." /></td>";
				 echo "<td><input type='text' id='qte".$i."' name='qte".$i."' style='width: 95%;' onChange=\"changement('qte');this.value=validation(this.value);\" value=".$facture['qte'][$i]." /></td>";
				 echo "<td><input type='text' id='pri".$i."' name='pri".$i."' style='width: 95%;' onChange=\"changement('pri');this.value=validation(this.value);\" value=".$facture['pri'][$i]." /></td>";
				echo "</tr>";
				$i++;
			} ?>
			<tr style="border-color:#3C4E58;">
			 <td><input type='text' id='des<?php echo $i; ?>' name='des<?php echo $i; ?>' style="width: 95%;" onChange="changement('des');" /></td>
			 <td><input type='text' id='qte<?php echo $i; ?>' name='qte<?php echo $i; ?>' style="width: 95%;" onChange="changement('qte');this.value=validation(this.value);"/></td>
			 <td><input type='text' id='pri<?php echo $i; ?>' name='pri<?php echo $i; ?>' style="width: 95%;" onChange="changement('pri');this.value=validation(this.value);"/></td>
			</tr>
		</tbody>
		</table>
		<input type='button' value='Ajouter une ligne' onClick="addInput();" />
		<input type='submit' name="submit" value='Enregistrer la facture' style="float:right;" />
	</form>
Le but de ce code est que quand je modifie une input, php initie une session.

Mais quand je fait un test, toutes mes conditions sont vraies:

J'ai dans enregistrerModif.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
if(isset($_SESSION['chgt']['date']) && $_SESSION['chgt']['date'] == true) {
	unset($_SESSION['chgt']['date']);
	echo "DATE changé";
}
 
if(isset($_SESSION['chgt']['ca']) && $_SESSION['chgt']['ca'] == true) {
	unset($_SESSION['chgt']['ca']);
	echo "CA changé";
}
Résultat de la page: CA changé, DATE changé
Pourtant, sur ma page d'origine, pour mon débug j'ai mis les alert() qui ne sonnent pas pour rien.

Avez vous une petite idée ?