feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[QUOTE=Onslaught]show us more of the code, like where you define $newpath0
Also, show us the exact error your getting now please.[/QUOTE]
[syntax="html"]
// Hide and show image script.
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function blocking(nr)
{
if (document.layers)
{
current = (document.layers[nr].display == 'none') ? 'block' : 'none';
document.layers[nr].display = current;
}
else if (document.all)
{
current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
document.all[nr].style.display = current;
}
else if (document.getElementById)
{
vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
document.getElementById(nr).style.display = vista;
}
}
// Javascript fuction for changing image ID "noimage"
function changePic(fe){
var opt_key = fe.selectedIndex;
var fileName = fe.options[opt_key].value;
document.getElementById('noimage').src=fileName;
return true;
}
// -->
</script>
<br>
//Begin, drop down box
Image :<br>
<center><select name="image[]" onchange="changePic(this);" multiple size="10">
<option SELECTED>[Choisir une image]</option>
[/syntax]
Code: Select all
<?php
//PHP generating the option for the drop down, recursive image
//search
function recur_dir($dir)
{
$dirlist = opendir($dir);
while ($file = readdir ($dirlist))
{
if ($file != '.' && $file != '..')
{
$newpath = $dir.'/'.$file;
$newpath2 = substr($newpath1, 0, -4);
$newpath0 = basename($newpath2,".*");
$level = explode('/',$newpath);
if (is_dir($newpath))
{
$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'kind'=>'dir',
'mod_time'=>filemtime($newpath),
'content'=>recur_dir($newpath));
echo '<option onclick=\'blocking(\''.$newpath0. ''\); return true;\'>'.substr($newpath, 7).'</option>';
echo '\n\r';
}else{
$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'kind'=>'file',
'mod_time'=>filemtime($newpath),
'size'=>filesize($newpath));
echo '<option onclick=\'blocking(\''.$newpath0. ''\); return true;\'>'.substr($newpath, 7).'</option>';
echo '\n\r';
}
}
}
closedir($dirlist);
return $mod_array;
}
recur_dir('Images');
echo '</select></center>';
//End of the geration of the dropdown box.
echo '<br>';
//a no image image for the first load.
echo '<center><img src="peuplies-1-man-small.bmp" width="100" id="noimage" align="center"></center>';
//Another recursive image search that display img tag in html for
//the hide an show script on top.
function recursi_dir($dir)
{
$dirlist1 = opendir($dir);
while ($file = readdir ($dirlist1))
{
if ($file != '.' && $file != '..')
{
$newpath1 = $dir.'/'.$file;
$level = explode('/',$newpath1);
if (is_dir($newpath1))
{
$mods_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath1,
'name'=>end($level),
'kind'=>'dir',
'mod_time'=>filemtime($newpath1),
'content'=>recursi_dir($newpath1));
echo '<img src="'.$newpath1.'" width="100" ID="'.$newpath0.'" title="'.$newpath1.'" alt="'.$newpath1.'">';
}else{
$mods_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath1,
'name'=>end($level),
'kind'=>'file',
'mod_time'=>filemtime($newpath1),
'size'=>filesize($newpath1));
echo '<img src="'.$newpath1.'" width="100" ID="'.$newpath0.'" title="'.$newpath1.'" alt="'.$newpath1.'">';
}
}
}
closedir($dirlist1);
return $mods_array;
}
recursi_dir('Images');
?>
Now. the problem that I have now is that the onclick of the option populate the first time :
Code: Select all
onclick=\'blocking(\''.$newpath0. '\'); return true;\'
When I run the code and check the source code :
Code: Select all
onclick='blocking(' '); return true;'
???
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]