need help with directory list to popups...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kathryn
Forum Newbie
Posts: 1
Joined: Tue Nov 19, 2002 11:20 pm

need help with directory list to popups...

Post 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>" ;
?>
sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

Post 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;
Post Reply