Problème d'ancre html # avec PHP

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Problème d'ancre html # avec PHP

par Truc » 03 déc. 2007, 23:28

Modération :
Puisque ta question est résolue, j'ajoute le tag [Résolu] (voire délestage, on y comprend rien de toute façon :? )
pour indiquer aux personnes qui voudront consulter ce sujet qu'il contient une solution.

Tu peux réaliser cette opération toi-même
en cliquant sur le bouton Image qui s'affiche en haut à gauche de ce sujet
si tu as posté le 1er message en tant que membre (inscrit et identifié).

Alors... inscris-toi !!! ;)

par Manuphi » 03 déc. 2007, 23:18

On m'a donné la solution sur un autre forum, alors si ça peut aider d'autres ici, la voici :

Code : Tout sélectionner

<div id="carre"> <?php $chemin='/'; $page1='index.php?img=img1#img1'; $page2='index.php?img=img2#img2'; $page3='index.php?img=img3#img3'; $page4='index.php?img=img4#img4'; $page5='index.php?img=img5#img5'; $page6='index.php?img=img9#img6'; $page7='index.php?img=img7#img7'; $page8='index.php?img=img8#img8'; $page9='index.php?img=img9#img9'; ?> <a class="carre" <?php if($_GET['img']=='img1' OR !isset($_GET['img'])){ echo'id="active_menu"';} echo 'href="'.$page1.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img2') { echo'id="active_menu"';} echo 'href="'.$page2.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img3'){ echo'id="active_menu"';} echo 'href="'.$page3.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img4'){ echo'id="active_menu"';} echo 'href="'.$page4.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img5') { echo'id="active_menu"';} echo 'href="'.$page5.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img6') { echo'id="active_menu"';} echo 'href="'.$page6.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img7'){ echo'id="active_menu"';} echo 'href="'.$page7.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img8'){ echo'id="active_menu"';} echo 'href="'.$page8.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_GET['img']=='img9') { echo'id="active_menu"';} echo 'href="'.$page9.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> </div>

par Victor BRITO » 03 déc. 2007, 22:14

Un id étant unique, s'il y a plusieurs carrés verts concernés, mieux vaut opter pour l'attribut class="active_menu".

Problème d'ancre html # avec PHP

par Manuphi » 03 déc. 2007, 19:04

Bonjour,
je cherche à attribuer un id="active_menu" sur des ancres html placées dans un container.
Comme mes explications ne sont peut-être pas très claires, voici le lien pour visualiser :
http://tourvivante.manuphi.fr/index.php
Il s'agit du menu avec les petits carrés verts en bas.
Avec id="active_menu", le petit carré doit être vert.
Sans id="active_menu", le petit carré doit être transparent.

Pour mieux comprendre encore voici le code :

Code : Tout sélectionner

<div id="carre"> <?php $chemin='/'; $page1='index.php'; $page2='index.php#img2'; $page3='index.php#img3'; $page4='index.php#img4'; $page5='index.php#img5'; $page6='index.php#img6'; $page7='index.php#img7'; $page8='index.php#img8'; $page9='index.php#img9'; $ancre='<script language="javascript1.2">document.write(window.location.hash);</script>'; ?> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page1) echo'id="active_menu" href="'.$page1.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page2) echo'id="active_menu" href="'.$page2.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page3) echo'id="active_menu" href="'.$page3.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page4) echo'id="active_menu" href="'.$page4.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page5) echo'id="active_menu" href="'.$page5.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page6) echo'id="active_menu" href="'.$page6.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page7) echo'id="active_menu" href="'.$page7.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page8) echo'id="active_menu" href="'.$page8.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> <a class="carre" <?php if($_SERVER['PHP_SELF'].$ancre=$chemin.$page9) echo'id="active_menu" href="'.$page9.'">';?> <img src="img/transparent.png" width="24" height="19" border="0"></a> </div>
Là tous les carrés sont verts alors qu'il ne devrait y avoir qu'un carré vert et les autres transparents.
Comme vous l'aurez compris, je suis pas loin d'être nul en php ...
Merci de vos idées et explications détaillées.