Greetings!

I'm having a problem showing a set of records using jQuery. When I click in the designated link, the script only shows the first record that comes from the database. Am I doing something wrong?

Here's the code


jQuery

$(document).ready(function() {
//hides the slickbox as soon as the DOM is ready
  $('div.contentor_imagens').hide();
 //shows the slickbox on clicking the noted link
});
function showEtiq(whichDiv) {
	showThis = "#contentor_imagens" + whichDiv;
	$(document).ready(function() {
	$(showThis).toggle("slow");
 });
}

HTML/PHP

echo'<div class="contentor_upload_galeria" >
				
<div class="img_port_options" id="img_port_options'.$id.'">
<a onclick="showSup('.$id.')"><div class="img_manage_up"></div></a>
<div class="img_manage_mup"></div>
<a onclick="showEtiq('.$id.')"><div class="img_manage_edit"></div></a> //DIV THAT IS CLICKED TO TRIGGER THE FUNCTION
</div>
				
	
				/*

DATABASE QUERY STUFF HERE...

*/		

//BLOCK TO BE SHOWN. IT ONLY SHOWS THE FIRST RECORD COMING FROM DB


echo'<div class="etiquetas_imagens"  id="contentor_imagens'.$id.'">
<div class="titulo_etiq_imagem">'.$row2['descricao'].'</div>
<div class="botoes_comando">
<a href="#"><div class="visualiza" id="visualiza"></div></a>
<a href="view.php?id='.$row2['ID'].'"><div class="edita"></div></a>
<a href="../crud/delete.php?id='.$row2['ID'].'&mod='.$table.'"><div class="elimina" id="delete"></div></a>
</div>
						
<div class="contentor_visualiza" id="contentor_visualiza'.$id.'">
<img src="'.$row2['caminho'].'" title="'.$row2['descricao'].'"></img>
</div>
				
</div>';

Thanks in advance for all the help!

Cheers!

Subtract jQuery from your equation.

Does it only show one result from the database with out the use of jQuery? That should be working first before we start worrying about how to present it with jQuery.

No, before hidding the div element, all the records were displaying correctly!

I bet it is being caused by this variable "whichDiv" that you have in your jQuery code. How is this being populated. Also, What happens when you remove it from the "showThis" variable like so:

function showEtiq(whichDiv) {
	showThis = "#contentor_imagens";
	$(document).ready(function() {
	$(showThis).toggle("slow");
 });

The "whichDiv" variable is responsible for determining which div need to be poped out, as all of them are populated with database records, so, for each record, and in order to give the show/hide effect uniquely to each record, I need to diferentiate each one and send that unique ID to that variable. If i remove that variable, it will only pop-out the same 1st record for every diferent ID's.

The problem is that, for each gallery (this one in particular is related to a portfolio with several user defined galleries so, i'll call it galleries), I want to list all the images it has, and apply them certain operations (CRUD, etc). So, for each gallery I want to show/hide the associated images with that gallery. The problem, as I said above, is that, when I click the button to trigger those records, for each diferent gallery it only pops the first associated record.

bump! Anyone? I really need this one done! Any kind soul?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.