|
La Communauté Webmaster 
| Pages: [1] |
 |
|
|
|
Auteur |
Sujet: Problèmes de menu déroulant simple XHTML avec PHP en externe... (Lu 946 fois) |
|
 |
Problèmes de menu déroulant simple XHTML avec PHP en externe...
« sur: le 20-12-2003 a 11:38:45 » |
|
Dyptowo
Membre récent

Hors-Ligne
Sexe: 
Messages: 28

|
Bonjour,
J'ai de petits problèmes avec mon semblant de code php, et je souhaiterai une aide de votre part si c'est possible.
Voilà mon problème :
J'ai fait un petit menu déroulant avec bouton "submit" en XHTML (afin de conserver la navigabilité avec clavier) en relation avec une page php externe. Ce menu ce compose de différents choix : Certains sont "actifs", c'est à dire qu'ils mènent effectivement vers d'autres pages XHTML, d'autres sont grisés et sont "inactifs", c'est à dire qu'ils ne mènent vers aucunes pages. De plus, le lien de la page actuellement visitée est aussi sans lien (mais pas grisée), afin d'éviter qu'un internaute clique sans arrêt sur Ok pour recharger la page inutilement ce qui gonflerait le nombre de requêtes (succés) pour rien.
Mais quand je choisi un choix grisé (ou sur le lien de la page active) et que je clique sur "Ok", j'ai une erreur 404 :
Not Found The requested URL /A0 was not found on this server. |
|
Voici en partie le code XHTML correspondant à ce menu déroulant :
<div class="form"> <form method="post" action="../../pagephp.php" enctype="multipart/form-data" id="post"> <legend>Sélectionnez un groupe :</legend>
<select name="groupes" size="1"> <option>Sélectionnez un groupe :</option> <option class="gris">A0</option> <option value="../../groupes/a9/groupe_1.html"> A9</option> <option class="gris">B0</option> <option class="gris">C0</option>
<option value="../../groupes/d0/groupe_1.html">D0</option> <option value="../../groupes/d2/groupe_1.html"> D2</option> <option> D5</option> <option class="gris">E0</option> <option class="gris">F0</option> <option value="../../groupes/f5/groupe_1.html"> F5</option>
<option value="../../groupes/f8/groupe_1.html"> F8</option> <option class="gris">G0</option> <option value="../../groupes/g1/groupe_1.html"> G1</option> <option value="../../groupes/g2/groupe_1.html"> G2</option> <option value="../../groupes/g8/groupe_1.html"> G8</option> <option class="gris">H</option> [...] </select>
<button id="submit" value="submit" type="submit">Ok</button> </form> </div> |
|
Et voici ci-dessous le code php correspondant (pagephp.php située dans la racine du site) :
<?php if ( (isset($_POST['groupes'])) && ($_POST['groupes'] != '') ) { header('Location: '.$_POST['groupes']); } ?>
Une capture d'écran du menu en question :

Exemple concret du problème : Je suis par exemple sur la page http://www.mon_de_domaine.com/groupes/d0/groupe_1.html (groupe D0) : 1/ J'ouvre le menu déroulant, choisi le lien grisé CO, et je clique sur Ok, et je me retrouve devant la fameuse page d'erreur 404 !
Alors que je souhaite qu'il ne se passe rien.
Not Found The requested URL /CO was not found on this server. |
|
2/ Ou encore, si je choisi un même choix que la page actuelle, soit le choix D0, parei :
Not Found The requested URL /D0 was not found on this server. |
|
Là aussi, je souhaite qu'il ne se passe normalement rien.
Je pense ne pas pouvoir être plus précis sur mon problème. 
Que dois-je faire pour éviter cette erreur tout en gardant le même menu déroulant ?
J'attends votre réponse avec impatience.
Merci beaucoup. |
|
|
|
|
|
|
 |
Re:Problèmes de menu déroulant simple XHTML avec PHP en externe...
« Répondre #1 sur: le 20-12-2003 a 18:57:27 » |
|
|
|
|
 |
Re:Problèmes de menu déroulant simple XHTML avec PHP en externe...
« Répondre #2 sur: le 20-12-2003 a 19:11:54 » |
|
ric
Membre récent

Hors-Ligne
Sexe: 
Messages: 56

jj
|
J'ai retrouvé ceci qui pourrait t'aider. ----------- A much needed script is the select box navigation. The user sees a select box as below, selects a destination and the new page is automatically loaded. Try the box below, then return to this pageTop of Form 1 Bottom of Form 1
You'll need to put the following HTML in the page: <SELECT NAME=navi onChange="go()"> <OPTION VALUE=''>--- Select your destination --- <OPTION VALUE="js.html">General Introduction <OPTION VALUE="placejs.html">Placing JavaScripts <OPTION VALUE="links.html">JavaScript Links </SELECT> First of all, put the correct links in the VALUE of the options. Then add an onChange event handler. If the user changes the select box, this event handler calls the script go() which loads the new page. This script is very simple: function go() { box = document.forms .navi; destination = box.options[box.selectedIndex].value; if (destination) location.href = destination; } First, I define a variable box, because I'm too lazy to type document.forms.navi twice in the next line. Then I take the value of the option the user has selected and put it in destination. As we put the correct links in the VALUE of the options, the correct URL now ends up in destination. For a further explanantion of this line of code, please see the Introduction to forms <http://www.xs4all.nl/~ppk/js/forms.html> page. Then I check if destination exists. The reason for this is, that the first option (the purely ornamental --- Select your destination ---) has no value. If the user selects the first option, nothing should happen. If everything is OK, we load the correct URL into location.href and the page is loaded. ------- Bon dimanche |
|
|
|
|
| Pages:
[1] |
|
|
|
| |
|
|