poniższy skrypt wyświetla mi prawidłowo drzewo plików i folderów:
<script type="text/javascript">
function showSubs(topicid)
{
var subs = document.getElementById("folder" + topicid);
if (subs.style.display == "none")
{
subs.style.display = "block";
}
else
{
subs.style.display = "none";
}
}
</script>
<?php
$listDirCount = 0;
function listDir($path = ".")
{
{
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..")
{
if (is_dir($path . "/" . $file)) {
$folders[] = $path . "/" . $file;
}
else
{
$files[] = $file;
}
}
}
for ($i = 0; $i < count($folders); $i++) {
$listDirCount++;
echo "<a href=\"listing.php\" onclick=\"showSubs($listDirCount)\">" . basename($folders[$i]) . "</a><br/>\n"; echo '<div id="folder' . $listDirCount . '" style="margin-left: 15px; margin-right: 10px; display: none;">'; listDir($folders[$i]);
}
for ($i = 0; $i < count($files); $i++) {
echo "{$files[$i]}<br/>\n"; }
}
}
listDir();
mam jednak problem z javascript - po kliknięciu na folder powinna mi się wyświetlić zawartość danego folderu, po powtórnym kliknięciu powinien nastąpić powrót. Jednak obecnie po kliknięciu na moment jedynie wyświetla mi się zawartość i zaraz następuje powrót.