Partage
  • Partager sur Facebook
  • Partager sur Twitter

Hide/show div dans une boucle php.

Le hide/show fonctionne mais n'agit que sur un un unique div

Sujet résolu
    20 août 2010 à 0:32:04

    Bonjour à vous amis zéros !

    Voilà mon soucis, dans une page de mon site, voilà ce la boucle que je créée :

    <?php	while($donnees=mysql_fetch_array($check_classe))
    	{ 
    	$reseau_ID=$donnees['ID']; 
    	?>			
              <br/>Nom du réseau : <?php echo $_SESSION['Etablissement'] ; ?> 
    <?php echo $_SESSION['User']; ?> 
    <?php echo $classe; ?> 
    <img src="Images/home_com_simple.jpg" onClick="hide_div(this.value)">
    <img src="Images/home_pub_simple.jpg" onClick="show_div(this.value)">
      	  <div id="<?php echo $reseau_ID; ?>">
    	  <?php
    	  include("update_reseau.php");
    	  include("update_reseau_prof.php");
    	  ?>
    	  </div>
    	  <code type="javascript"><script type="text/javascript">
    	  function hide_div(Reseau)
    	  {
    	  var elmt = document.getElementById("<?php echo $reseau_ID; ?>");
    	  elmt.style.display = "none";
    	  }	
    	  function show_div(Reseau)
    	  {
    	  var elmt = document.getElementById("<?php echo $reseau_ID; ?>");
    	  elmt.style.display = "block";
    		}	
              </script></code>
    	  <?php
    	}
    


    Et le résultat est que, lorsque j'obtiens 3 ou 4 div différents, les boutons pourtant présent dans chaque div, n'agissent que sur un seul et unique div.
    Pouvez vous m'aidez ?
    Cordialement, Ewen.
    • Partager sur Facebook
    • Partager sur Twitter
      20 août 2010 à 0:55:52

      Salut, ici le php on s'en fout, il nous faut le code source généré. Et si ça n'agit que sur le DERNIER div de la boucle, alors visiblement tu as besoin des closures
      • Partager sur Facebook
      • Partager sur Twitter
        20 août 2010 à 1:08:26

        Merci pour ta réponse, mais mon niveau en JavaScript est limité...
        Les closures, ça me semble bien trop compliqué pour moi.
        Voilà le code source généré, les parties concernés sont entre les lignes : 71/218 et 238/369 (sauf erreure de ma part)

        Les functions JS sont bien générés plusieurs fois avec les bonnes cibles.
        Je précise que si je remplace <?php echo $reseau_ID ?> par une valeure, là, ça fonctionne. Mais evidemment, seulement sur un seul div.


        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
           <head>
               <title></title>
               <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
               <link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/profil.css" />
        	   <link rel="shortcut icon" href="Images/icone_usebook.ico" type="image/x-icon"/>
        		<link rel="icon" href="Images/icone_usebook.ico" type="image/x-icon"/>
           </head>
        
           
           <body>
        		<table id="head" >
        		<tr>
        			<td id="logo" align="center"> <a href="index.php" style="text-decoration:none;"><img src="../construction/Images/logo2.png" alt="Logo UseBook" border=0></a> </td>
        			<td id="pub_head"> <p> Ici, il y aura une pub et ce sera cool parce que ça me rendra riche. </p> </td>
        			<td id="user"> 	<head>
        
        		<link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/user_headbox.css" />
        	</head>
        	<body>
        <fieldset id="connexion"><table class="form">
        
        <tr style="text-align:center;width:100%;"><td><a href="deconnexion.php">Déconnexion</a></td></tr>
        					<tr style="text-align:center;width:100%;"><td style="text-align:center;width:100%;"><a href="admin_reseau.php">Administration réseau</a></td></tr>
        					
        </table>
        </fieldset>
        </body> </td>
        
        		</tr>
        		</table>
        		
        	<table style="width:100%">
        		<tr id="menu">
        			<td id="menu_menu" align="center"> <head>
               <link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/menu.css" />
        </head>
        <body>
        	<table class="home">
        
        		<tr>
        			<td class="td_home"><a href="index.php" class="Home"><img src="Images/house.png" class="Home_gif"></a></td> <!-- Ici, c'est la cellule du bouton Home, qui est noir et permet de revenir à la page d'accueil -->
        		</tr>
        		<tr rowspan=4 class="td_com"> <!-- On colle les cellules verticalement pour obtenir un bloc sans espaces. Ce sont les liens de Communication ! -->
        			<td><a href="index_com.php" class="Home_com">Communication</a></td></tr>
        		<tr class="td_com"><td><a href="profil.php" class="Com">Ma page</a></td></tr>
        		<tr class="td_com"><td><a href="contacts.php" class="Com">Mes contacts</a></td></tr>
        
        		<tr class="td_com"><td><a href="messagerie.php" class="Com">Ma messagerie</a></td></tr>
        		
        		<tr rowspan=3 class="td_orga"> <!-- On colle les cellules verticalement pour obtenir un bloc sans espaces. Ce sont les liens de organisation ! -->
        			<td><a href="index_com.php" class="Home_orga">Organisation</a></td></tr>
        		<tr class="td_orga"><td><a href="page.php" class="Orga">Mon dossier d'étude</a></td></tr>
        		<tr class="td_orga"><td><a href="page.php" class="Orga">Mes dossiers privés</a></td></tr>
        
        		<tr rowspan=3 class="td_pub"> <!-- On colle les cellules verticalement pour obtenir un bloc sans espaces. Ce sont les liens de pub ! -->
        
        			<td><a href="index_com.php" class="Home_pub">Publicité</a></td></tr>
        		<tr class="td_pub"><td><a href="page.php" class="Pub">Les réseaux publicitaires</a></td></tr>
        		<tr class="td_pub"><td><a href="page.php" class="Pub">Mes réseaux publicitaires</a></td></tr>
        		
        		
        		
        	</table>
        </body> </td>
        			<td id="profil" rowspan=2 valign="top"><head>
        	<link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/admin_reseau_contenu.css" />
        
        </head>
        			<br/>Nom du réseau : Jean Rostand YvesBorowice 1S1 <img src="Images/home_com_simple.jpg" onClick="hide_div(this.value)"><img src="Images/home_pub_simple.jpg" onClick="show_div(this.value)">
        			<div id="2">
        			<form method="POST" action ="update_reseau_account.php">
        <input type="text" style="display:none;" name="ID_reseau" value="2">
        <fieldset><legend>Selectionnez les contacts à ajouter à Jean Rostand YvesBorowice 1S1</legend>
        <table style="width:100%;">
        <td valign=top style="width:33%">
        <table id="result_ville">
        <caption>Résultats par ville</caption>
        			<tr>
        
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | 2ndF</span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="E.Schwald"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">E.Schwald</span><span style="font-size:12px"> | Schwald | Eric</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | 2ndF</span></td>
        			</tr>
        			</table>
        </td>
        
        <td valign=top style="width:33%">
        <table id="result_classe">
        <caption>Résultats par Lycée/Classe</caption>
        
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="HeleneHervagault"><img src="Images/HeleneHervagault.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">HeleneHervagault</span><span style="font-size:12px"> | Hervagault | Helene</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Blaincourt | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="CamilleFourcade"><img src="Images/CamilleFourcade.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">CamilleFourcade</span><span style="font-size:12px"> | Fourcade | Camille</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Lamorlaye | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="E.Schwald"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">E.Schwald</span><span style="font-size:12px"> | Schwald | Eric</span></td>
        			</tr>
        
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VincaMontmeat"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VincaMontmeat</span><span style="font-size:12px"> | Montmeat | Vinca</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        
        			<td colspan=2><span style="font-size:12px">Gouvieux | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VictorSereni"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VictorSereni</span><span style="font-size:12px"> | Sereni | Victor</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Coye-La-Forêt | Jean Rostand | </span></td>
        
        			</tr>
        			</table>
        </td>
        
        <td valign=top style="width:33%">
        <div style="width:100%;">
        <table id="result_nom">
        <caption>Résultats par Nom</caption>
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="HeleneHervagault"><img src="Images/HeleneHervagault.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">HeleneHervagault</span><span style="font-size:12px"> | Hervagault | Helene</span></td>
        			</tr>
        
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Blaincourt | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="CamilleFourcade"><img src="Images/CamilleFourcade.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">CamilleFourcade</span><span style="font-size:12px"> | Fourcade | Camille</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        
        			<td colspan=2><span style="font-size:12px">Lamorlaye | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="E.Schwald"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">E.Schwald</span><span style="font-size:12px"> | Schwald | Eric</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VincaMontmeat"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VincaMontmeat</span><span style="font-size:12px"> | Montmeat | Vinca</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Gouvieux | Jean Rostand | </span></td>
        			</tr>
        
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VictorSereni"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VictorSereni</span><span style="font-size:12px"> | Sereni | Victor</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Coye-La-Forêt | Jean Rostand | </span></td>
        			</tr>
        			</table>
        
        </div>
        </td>
        </table>
        <input type="submit" value="Ajouter ces contacts au réseau">
        </fieldset>
        </form><form method="POST" action="update_statut_account.php">
        <fieldset><legend>Selectionnez les contacts que vous voulez définir comme Professeurs (ne les choississez pas deux fois)</legend>
        <table style="width:100%;">
        <td valign=top style="width:33%">
        <table id="result_ville">
        <caption>Résultats par ville</caption>
        </table>
        </td>
        
        <td valign=top style="width:33%">
        
        <table id="result_classe">
        <caption>Résultats par Lycée/Classe</caption>
        </table>
        </td>
        
        <td valign=top style="width:33%">
        <div style="width:100%;">
        <table id="result_nom">
        <caption>Résultats par Nom</caption>
        </table>
        </div>
        </td>
        </table>
        <input type="submit" value="Définir comme Professeurs">
        </fieldset>
        
        </form>			</div>
        			<script type="text/javascript">
        			function hide_div(Reseau)
        			{
        			var elmt = document.getElementById("2");
        			elmt.style.display = "none";
        			}	
        			function show_div(Reseau)
        			{
        			var elmt = document.getElementById("2");
        			elmt.style.display = "block";
        			}	
        			</script>
        						<br/>Nom du réseau : Jean Rostand YvesBorowice 2ndF <img src="Images/home_com_simple.jpg" onClick="hide_div(this.value)"><img src="Images/home_pub_simple.jpg" onClick="show_div(this.value)">
        			<div id="1">
        			<form method="POST" action ="update_reseau_account.php">
        <input type="text" style="display:none;" name="ID_reseau" value="1">
        <fieldset><legend>Selectionnez les contacts à ajouter à Jean Rostand YvesBorowice 2ndF</legend>
        <table style="width:100%;">
        <td valign=top style="width:33%">
        
        <table id="result_ville">
        <caption>Résultats par ville</caption>
        </table>
        </td>
        
        <td valign=top style="width:33%">
        <table id="result_classe">
        <caption>Résultats par Lycée/Classe</caption>
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="CamilleFourcade"><img src="Images/CamilleFourcade.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">CamilleFourcade</span><span style="font-size:12px"> | Fourcade | Camille</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Lamorlaye | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VincaMontmeat"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VincaMontmeat</span><span style="font-size:12px"> | Montmeat | Vinca</span></td>
        			</tr>
        
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Gouvieux | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VictorSereni"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VictorSereni</span><span style="font-size:12px"> | Sereni | Victor</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        
        			<td colspan=2><span style="font-size:12px">Coye-La-Forêt | Jean Rostand | </span></td>
        			</tr>
        			</table>
        </td>
        
        <td valign=top style="width:33%">
        <div style="width:100%;">
        <table id="result_nom">
        <caption>Résultats par Nom</caption>
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="CamilleFourcade"><img src="Images/CamilleFourcade.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">CamilleFourcade</span><span style="font-size:12px"> | Fourcade | Camille</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Lamorlaye | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VincaMontmeat"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VincaMontmeat</span><span style="font-size:12px"> | Montmeat | Vinca</span></td>
        			</tr>
        
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Gouvieux | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="VictorSereni"><img src="Images/picture.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">VictorSereni</span><span style="font-size:12px"> | Sereni | Victor</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        
        			<td colspan=2><span style="font-size:12px">Coye-La-Forêt | Jean Rostand | </span></td>
        			</tr>
        			</table>
        </div>
        </td>
        </table>
        <input type="submit" value="Ajouter ces contacts au réseau">
        </fieldset>
        </form><form method="POST" action="update_statut_account.php">
        <fieldset><legend>Selectionnez les contacts que vous voulez définir comme Professeurs (ne les choississez pas deux fois)</legend>
        <table style="width:100%;">
        <td valign=top style="width:33%">
        
        <table id="result_ville">
        <caption>Résultats par ville</caption>
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | 2ndF</span></td>
        
        			</tr>
        			</table>
        </td>
        
        <td valign=top style="width:33%">
        <table id="result_classe">
        <caption>Résultats par Lycée/Classe</caption>
        			<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="HeleneHervagault"><img src="Images/HeleneHervagault.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">HeleneHervagault</span><span style="font-size:12px"> | Hervagault | Helene</span></td>
        			</tr>
        
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Blaincourt | Jean Rostand | </span></td>
        			</tr>
        			</table>
        </td>
        
        <td valign=top style="width:33%">
        <div style="width:100%;">
        <table id="result_nom">
        <caption>Résultats par Nom</caption>
        			<tr>
        
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="FelixGanz"><img src="Images/Profil.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">FelixGanz</span><span style="font-size:12px"> | Ganz | Felix</span></td>
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Chantilly | Jean Rostand | </span></td>
        			</tr>
        						<tr>
        			<td rowspan=2><input type="checkbox" name="Select_user[]" value="HeleneHervagault"><img src="Images/HeleneHervagault.jpg" width=40 height=40></td><td><span style="color:green;font-size:16px">HeleneHervagault</span><span style="font-size:12px"> | Hervagault | Helene</span></td>
        
        			</tr>
        			<tr style="border-bottom:1px solid green;">
        			<td colspan=2><span style="font-size:12px">Blaincourt | Jean Rostand | </span></td>
        			</tr>
        			</table>
        </div>
        </td>
        </table>
        <input type="submit" value="Définir comme Professeurs">
        </fieldset>
        </form>			</div>
        
        			<script type="text/javascript">
        			function hide_div(Reseau)
        			{
        			var elmt = document.getElementById("1");
        			elmt.style.display = "none";
        			}	
        			function show_div(Reseau)
        			{
        			var elmt = document.getElementById("1");
        			elmt.style.display = "block";
        			}	
        			</script>
        			</td>
        		</tr>
        		<tr id="pub">
        			<td id="pub_pub"> <p>Futur box de pub !</p> </td>
        		</tr>
        		<tr id="foot">
        
        			<td id="foot_foot"> <head>
               <link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/foot.css" />
        </head>
        <body>
        <table>
        <tr>
        <td class="left"><a href="contact.php">Contact</a>
        </td>
        <td class="right"><a href="infos.php">A propos du site</a>
        </td>
        </tr>
        <tr>
        
        <td class="left"><a href="partenaires.php">Site Partenaire</a>
        </td>
        <td class="right"><a href="bugs.php">Bug connus</a>
        </td>
        </tr>
        <tr>
        <td class="left"><a href="chartre.php">Chartre</a>
        </td>
        </tr>
        </table>
        </body></td>
        			<td id="comment"><head>
               <link rel="stylesheet" media="screen" type="text/css" title="Design" href="../construction/CSS/general_comment.css" />
        
        </head>
        <body>
        <fieldset id="fieldset">
        <table style="width:100%;height:100%;">
        <form method="POST" action="send_comment.php">
        Pendant la phase de bêta, vous pouvez à chaque instant poster un commentaire sur la page où vous vous trouvez, ou reporter un bug : 
        <td id="td_COMMENT">
        <textarea name="Comment" id="Comment"></textarea>
        </td>
        <td id="td_OK">
        <input type="submit" id="Submit" Value="Poster">
        </td>
        </form>
        </table>
        </fieldset>
        </body>
        
        <!-- Ici, il faut poster le commentaire via JS, sinon l'utilisateur sera enlevé de la page où il était. On copiera donc le script de Verif_Pseudo de sign_in_form.php --> </td>
        		</tr>
        	</table>
        	
           </body>
        </html>
        
        • Partager sur Facebook
        • Partager sur Twitter
          20 août 2010 à 7:49:29

          C'est une sacrée boucherie ça !! :D

          Commençons par ceci :

          <img src="Images/home_com_simple.jpg" onClick="hide_div(this.value)">
          


          Tu codes en xHTML, alors écris <img /> et non <img>, et tous les attributs doivent être en minuscule.
          this dans un attribut, représente l'objet dans lequel est placé ce attribut. Ici, c'est ton image. Une image n'a pas de propriété value.

          Viennent ensuite tes fonctions :

          function hide_div(Reseau){
          	var elmt = document.getElementById("1");
          	elmt.style.display = "none";
          }	
          function show_div(Reseau){
          	var elmt = document.getElementById("1");
          	elmt.style.display = "block";
          }
          


          D'abord à quoi sert l'argument Reseau (ce fameux this.value) que tu n'utilises jamais dans le corps de la fonction ? Et par convention, on nomme les variables en lowerCamelCase. La majuscule est réserver au constructeur (Array(), Image(), Regexp()...)

          Ensuite, ton script n'a rien à faire en plein milieu du body. Le placement le plus conseillé, c'est tout à la fin, juste avant le </body>

          Résultat, tu ouvres deux balises <script> pour définir la même fonction. Problème, la deuxième fois que tu fais ça, la première est écrasée. Et ça te choque pas d'écrire deux fonctions avec quasiment le même corps ? Tu crois pas que c'est justement pour éviter d'écrire 10 fois les mêmes choses qu'on a inventer les fonctions ??

          Le plus simple pour te sortir d'affaire c'est de passer en argument à ta fonction l'id de la partie à cacher :

          <body>
            <img src="..." onclick="hide_div('1')" />
          
            <img src="..." onclick="hide_div('2')" />
          
            <script type="text/javascript">
            function hide_div(id){
                document.getElementById(id).style.display = 'none';
            }
            </script>
          </body>
          


          Je suis pas fan des attributs onclick et compagnie mais on va rester simple.

          Une dernière remarque, id="1" j'appelle pas ça un identifiant...
          • Partager sur Facebook
          • Partager sur Twitter
            20 août 2010 à 11:18:25

            Merci beaucoup pour le temps que tu m'accordes.

            Comme je te disais, mon niveau en JavaScript est limité, je ne l'ai pas vraiment appris. Pour l'instant, je m'étais contenté d'adapter des codes trouvés par ci par là...

            J'ai corrigé mon code, et ça fonctionne. Maintenant, je sais comment faire. Merci à toi (vraiment beaucoup).
            • Partager sur Facebook
            • Partager sur Twitter

            Hide/show div dans une boucle php.

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown