You need to call the js function when you click on the link.

The link is formed dynamically, immediately after the link with the image is formed, the image is formed well - with the same parameter, but the link by clicking on which you want to call the function does not work, the error ReferenceError: minIMG_1167 is not defined.

Code:

 while (false !== ($file = readdir($handle))) { $pos1 = stripos(strval($file), "min"); if ($pos1 !== false) { //echo '<img src="'.$path.iconv('cp1251', 'UTF-8', $file).'">'; $filem = str_replace("min", "", $file); $i++; if ($i==1) { echo "<div style='float:left;'><a class='group1 cboxElement' href='".$path.iconv('cp1251', 'UTF-8', $filem)."' style='padding:2px;'><img src='".$path.iconv('cp1251', 'UTF-8',$file)."'></a></br><a href='#' onclick='delfoto(".$file."); return false;'>Удалить</a></div>"; } else { echo "<div style='text-align:left;'><a class='group1 cboxElement' href='".$path.iconv('cp1251', 'UTF-8', $filem)."' style='padding:2px;'><img src='".$path.iconv('cp1251', 'UTF-8',$file)."'></a></br><span onclick='delfoto(".$filem.")'>Удалить</span></div>"; $i=0; } } } 

    1 answer 1

    You must put quotes for the function parameter delfoto

     echo " ... delfoto(\"".$file."\") ... "