...

View Full Version : js function to hide multiple div call in a loop with php



Jeff23
01-24-2012, 03:24 PM
Hi,

I have a problem with my script, I have a php request and the result is shown in a div, so there is several divs and their id is the "id" in the database, and I want that if we click on a link, it hides every divs...


Here is how I tried to do that:



<script type="text/javascript">
function visibilite(thingId)
{
var targetElement;
targetElement = document.getElementById(thingId) ;
targetElement.innerHTML = "" ;
}
</script>





$hide = "";
while($ligne=mysql_fetch_array($ress)){


$hide.= "visibilite('$ligne[id]'); ";


$return.= "<tr><td>$ligne[heure] - $ligne[fin]</td><td>$ligne[sport]</td><td>$ligne[salle]</td><td>$ligne[ville]</td><td>$dispo/$ligne[place]</td><td><div id=$ligne[id]>";

$return.= "<a href=# onClick=\"maFonctionAjax($ligne[id],$tennis); $hide return false\">Reserver</a>";

$return.= "</div></td></tr>";
}


Every div'id is the id in the database, with the onClick we call an ajax function and $hide which is the call for the function visibilite for each div

It works for some request, I don't know how is it possible because I can have the same number of results and sometimes it works, and sometimes not...

Does somebody can help me?

Thanks a lot!

Jeff



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum