I'm using PHP to list all sub-directories in gallery folder:
<div class="dropdown-gallery" id="dropdown-gallery" onchange="changeGallery(this)">
<select>
<?php
$galleries = scandir("./gallery");
foreach($galleries as $gallery){
echo("<option value='$gallery'>$gallery</option> ");
}
?>
</select>
</div>
I would like to operate on values of those optinos in JS, the problem is that this code:
<script>
function changeGallery(elem){
alert(elem.options[elem.selectedIndex].value);
alert(elem.value);
}
Returns Uncaught TypeError: Cannot read property 'undefined' of undefined in both alert cases
I was looking for a solution and found nothing that could help me