Entry
How can I read the filenames of files in a folder on a webserver and pass them to a Javascript Array
Apr 7th, 2008 22:35
ha mo, James Alexander, Nick Hearn,
Here's how I do it in my replay parser.
[/code]
<?php
$replays='';
$replays_dir = opendir('replays/');
while (false !== ($replay = readdir($replays_dir))) {
if (substr($replay,-4)=='.w3g') {$replays.=','.$replay;}
}
$replays = str_replace('.w3g','',$replays);
echo('<script type="text/javascript">
var replays=\''.substr($replays,1).'\'.split(",");
</script>');
closedir($replays_dir);
?>
[/code]
Then the javascript.
[code]
var j = 0;
var t;
var rcount = 0;
var rint = 2500;
function doreplays1() {
unsure=confirm("Please wait until all your replays are listed below!");
if (unsure==true) {
j=0; rcount=replays.length;
document.getElementById('hideme').innerHTML='';
doreplays();
}
}
function doreplays() {
if (j<rcount) {
openpage('example.php?id='+replays[j]);
document.getElementById('answer').innerHTML+=replays[j]+'<br/ >';
j++;
t=setTimeout("doreplays()",rint);
} else {
clearTimeout(t);
document.getElementById('answer').innerHTML+='<br/ >Thats all of
them.<br/ >';
}
}
/// winopt along with other variables here is adjustable.
function openpage(ulink) {
switch(winopt) {
case 0: document.getElementById('1').src=ulink; break;
case 1: window.open(ulink); break;
case 2: popupwin=window.open
(ulink,'info','width=800,height=300,scrollbars=yes,menubar=yes,resizable
=yes'); break;
}
}
[/code]
Not sure if this will help or now
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com