Bonjour,
J'ai un soucis en javascript. En faites, je n'arrive plus à recuperer les valeurs utiliser dans le onchange apres un submit.
Du coup ici, toutes mes variables s'actualisent en direct, par contre, je n'arrives pas à les recuperer derriere dans le POST.
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 <?php echo "<head> <script type=\"text/javascript\"> function updateTotal(){ //On récupère le total var total=0; total += parseInt(document.getElementById('selRange1').innerHTML); total += parseInt(document.getElementById('selRange2').innerHTML); total += parseInt(document.getElementById('selRange3').innerHTML); total += parseInt(document.getElementById('selRange4').innerHTML); total += parseInt(document.getElementById('selRange5').innerHTML); total += parseInt(document.getElementById('selRange6').innerHTML); //Puis on ajoute dans la case document.getElementById('case_total').innerHTML=total; } </script> </head>"; if ($_POST['verif'] != 1) { echo "<form action=\"mapage.php\" method=\"post\">"; echo "<table cellspacing=\"0\" cellpadding=\"3px\" rules=\"rows\" style=\"border:solid 1px #777777; border-collapse:collapse; font-family:verdana; font-size:11px; margin-left:auto; margin-right:auto;\">"; echo "<caption>Composition :</caption>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 1</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam1\" onchange=\"document.getElementById('selRange1').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin-left: 9%;\"><span id=\"selRange1\">0</span> %</th>"; echo "</tr>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 2</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam2\" onchange=\"document.getElementById('selRange2').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin-left: 9%;\"><span id=\"selRange2\">0</span> %</th>"; echo "</tr>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 3</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam3\" onchange=\"document.getElementById('selRange3').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin-left: 9%;\"><span id=\"selRange3\">0</span> %</th>"; echo "</tr>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 4</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam4\" onchange=\"document.getElementById('selRange4').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin: margin-left: 9%;\"><span id=\"selRange4\">0</span> %</th>"; echo "</tr>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 5</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam5\" onchange=\"document.getElementById('selRange5').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin-left: 9%;\"><span id=\"selRange5\">0</span> %</th>"; echo "</tr>"; echo "<tr style=\"background-color:lightgrey;\">"; echo "<th style=\"width:140px;\">Famille 6</th>"; echo "<th> <input type=\"range\" style=\"margin-left: 15%; name=\"fam6\" onchange=\"document.getElementById('selRange6').innerHTML = this.value; updateTotal();\" value=\"0\" step=\"5\" max=\"100\" min=\"0\"></input></th>"; echo "<th style=\"width:50px;\"><span style=\"border: 2px solid black; margin-left: 9%;\"><span id=\"selRange6\">0</span> %</th>"; echo "</tr>"; echo "</table>"; echo "<p style=\"width:100px;\">Votre compo est remplie à: <span style=\"border: 2px solid black; margin: 0px 0px 0px 0px;\"><span id=\"case_total\">0</span> %</p>"; echo "<input type=\"hidden\" name=\"verif\" value=\"1\">"; echo "<input type=\"submit\" name=\"submit\" value=\"Valider votre choix\" />"; echo "</form>"; } else if ($_POST['verif'] == 1) echo 'valeur des compos : 1= '.$_POST['fam1'].' 2= '.$_POST['fam2'].' 3= '.$_POST['fam3'].' 4= '.$_POST['fam4'].' 5= '.$_POST['fam5'].' 6= '.$_POST['fam6'].''; ?>
Est ce qu'il est possible à un moment de dire que $mavariablephp = resultat de SelRange1 par exemple ?
Bonne journée
Partager