0

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!

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by fantasma
0

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.

0

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

Edited by fantasma: n/a

0

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");
 });
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.