I'm having a lot of trouble making the links in my directory list open in popups. I can't figure out how to pass a variable between my PHP and Javascripts. Can anyone help? These are the scripts that I'm trying to use, but yeah, it's not working cuz I need the popurl (in the js) to be "2002.php?mydate=$filenames[$i]"
<script language="JavaScript" type="text/javascript">
function openpopup(){var popurl="2002.php"
winpops=window.open(popurl,"","width=440,height=320, scrollbars")
}
</script>
<?php
$default_dir = "./2002";
if(!($dp = opendir($default_dir))) die ("Cannot open $default_dir.");
while($file = readdir ($dp)) $filenames[] = $file;
closedir($dp);
sort ($filenames);
for ($i=0; $i < count ($filenames); $i++)
if ($filenames[$i] != '.' && $filenames[$i] != '..')
echo "<a href=javascript:openpopup()>$filenames[$i]</a><br>" ;
?>
need help with directory list to popups...
Moderator: General Moderators
I am not an expert or anything. i am just learning but could you do something like:
Code: Select all
<?php
$default_dir = "./2002";
if(!($dp = opendir($default_dir))) die ("Cannot open $default_dir.");
while($file = readdir ($dp)) $filenamesї] = $file;
closedir($dp);
sort ($filenames);
for ($i=0; $i < count ($filenames); $i++)
if ($filenamesї$i] != '.' && $filenamesї$i] != '..')
echo "<script language='JavaScript' type='text/javascript'>
function openpopup(){var popurl='2002.php2002.php?mydate=$filenamesї$i]'
winpops=window.open(popurl,'','width=440,height=320, scrollbars')
}
</script>"
echo "<a href=javascript:openpopup()>$filenamesї$i]</a><br>" ;
?>