Page 1 of 1

need help with directory list to popups...

Posted: Tue Nov 19, 2002 11:20 pm
by kathryn
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>" ;
?>

Posted: Thu Nov 21, 2002 11:47 am
by sublevel4
I am not an expert or anything. i am just learning but could you do something like:

Code: Select all

&lt;?php

$default_dir = "./2002"; 
if(!($dp = opendir($default_dir))) die ("Cannot open $default_dir."); 
while($file = readdir ($dp)) $filenames&#1111;] = $file; 
closedir($dp); 
sort ($filenames); 
for ($i=0; $i &lt; count ($filenames); $i++) 
if ($filenames&#1111;$i] != '.' &amp;&amp; $filenames&#1111;$i] != '..')

echo "&lt;script language='JavaScript' type='text/javascript'&gt; 
function openpopup(){var popurl='2002.php2002.php?mydate=$filenames&#1111;$i]' 
winpops=window.open(popurl,'','width=440,height=320, scrollbars') 
} 
&lt;/script&gt;"

echo "&lt;a href=javascript:openpopup()&gt;$filenames&#1111;$i]&lt;/a&gt;&lt;br&gt;" ;

?&gt;