Page 1 of 1

Select multiple and show.

Posted: Wed Jul 18, 2007 4:20 pm
by Peuplarchie
Good day to you all,
Here I have a piece of code which I would like it to be able to select multiple image and display them right away.

I know how to do a multiple select box but how to make the the selection to be diplaying i don't know.

I would imagine that it a request for ajax but, I have posted it here cause my code is mostly php.

Code: Select all

<td width="200" valign="top" align="left" class="black">
<script language="JavaScript" type="text/javascript" >
function changePic(fe){
var opt_key = fe.selectedIndex;
var fileName = fe.options[opt_key].value;
document.getElementById('noimage').src=fileName;
return true;
}
</script>
<br>
Image :<br>
<center><select name="image" onchange="changePic(this);">
  <option>[Choisir une image]</option>
<?php

   function recur_dir($dir)
   {
       $dirlist = opendir($dir);
       while ($file = readdir ($dirlist))
       {
           if ($file != '.' && $file != '..')
           {
               $newpath = $dir.'/'.$file;
               $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>'.$newpath.'</option>';
               }else{
  
                   $mod_array[] = array(
                           'level'=>count($level)-1,
                           'path'=>$newpath,
                           'name'=>end($level),
                           'kind'=>'file',
                           'mod_time'=>filemtime($newpath),
                           'size'=>filesize($newpath));
			echo '<OPTION value='.$newpath.'>'.$newpath.'</option>';
              }
           }
       }
       closedir($dirlist);
       return $mod_array;
   }
   
   print_r(recur_dir('Images'));
echo '</select></center>';


?>
<br>
<center><img src="peuplies-1-man-small.bmp" width="100"  id="noimage" align="center"></center>


Do somebody have a idea ?

Thanks !

Posted: Wed Jul 18, 2007 4:24 pm
by feyd
This thread looks very familiar.

Posted: Wed Jul 18, 2007 4:50 pm
by Peuplarchie
Yes I got it working, it's truth.
But now I want to had something else and I' little lost.

It's not the same question.

Posted: Wed Jul 18, 2007 4:55 pm
by feyd
Then you're going to need to explain your problem more, I would say.

Posted: Thu Jul 19, 2007 11:32 am
by Peuplarchie
this script is only for choosing an image that will be put with the message, part that you dont see of the code.

No I would like to have the same script but for as many as the client want to put.

How would I go about that ?