This might be very obvious however I cannot seem to solve it.
I have the following option menu :
<select name="Image2" onChange="showImage(this.value)">
<option value="" selected="selected"></option>
<?php
$dir = "../somefolder";//your path
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
echo "<option value='". $filename . "'>" . $filename . "</option>"; }
sort($files);
?>
</select>
<div id="image_div"></div>
<script type="text/javascript">
function showImage(value)
{
var img = "<img src='../somefolder/"+value+"' />";
document.getElementById('image_div').innerHTML = img;
}
</script>
Which works fine, but all the files are not sorted a-->z is there a way to do this, I have over 100 files in this folder? Any help Welcome