I have a code that lists a div with contents through foreach and echo in php, this div expands as I enter the data in it, I already have a js show / hide code that is working normally, but in that case it shows / hides only the 1 content with the foreach listing several.
Follow the codes used to do this.
Show / hide button
if (isset( $_POST['ID'] ) ) {
echo "<div id='downloadbox'><a href=javascript:showhide('downloadlinks')>
Arquivos</a>
</div>";
}
Code to list div to be hidden
foreach($files as $file){
if(!in_array($file,$exclude)){
if (trim($IDD) == trim("121")){
echo "<div id=downloadlinks>".$file."<div id=botaodownload><a href=baixar.php?arquivo=pasta/".$ID."/".$file.">Download<i class=material-icons>file_download</i></div></a>
<div id=excluir><a href=deleta.php?delete=pasta/".$ID."/".$file." onclick='deletar( this, event );'>Excluir</a></div></div>";
}else{
echo "<div id=downloadlinks>".$file."<div id=botaodownload><a href=baixar.php?arquivo=pasta/".$ID."/".$file.">Download<i class=material-icons>file_download</i></div></a></div>";
}
}
}
JS SHOWHIDE
function showhide(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'inline-block') ? 'none' : 'inline-block';
}