hi
I need to create a drop down menu populated with the file names (without extension) stored in an array. I got these file names through 'glob' function in php as follows:
$txtFilesWithPath = glob("" . $myDir . "*.txt");
<select name="arrType" onChange="autoSubmit();">
<option value="null" disabled="disabled" selected = "selected">-------------Select Option--------------</option>
<?php
foreach ($txtFilesWithPath as $fn)
{
$x = basename($fn);
$arrTypeVal = substr($x, 0,strrpos($x,'.')); //remove the file extension
echo ('<option value= '. $fn . ($arrType == $arrTypeVal ? ' selected = "selected">' : '>') . $arrTypeVal. '</option>');
}
echo"</select><br>";
} //end if
?>
This code gives a correct value for the selection but always show the last element of the array in select box no matter what I select from drop down menu.
Pl. help
Thanks