"brett" <br*********@hotmail.com> wrote in message
news:G6********************@adelphia.com...
On my website I have a directory filled with possible files that a
user can
select to download. Rather than going to the directory itself to
download,
I'd like the user to be able to select a single file from a select box
embedded on an html page. I'm looking for a way that I can use
javascript to
do this for me. I know that perl could get these filenames for me
easily,
but is javascript able to put these into a select box once I have Perl
parse
the directory? Is this insecure or is there a better way to do this?
If you are using Perl to parse the directory, use it to populate the
<select> as well. Parsing the list of files using Perl, then using Perl
to output client-side JavaScript that can populate a <select> is an
extra step and places a requirement on your end-user to have JavaScript
enabled.
print "content-type: text/html\n\n";
if (opendir(DIR, "$full_path"))
{
@files = grep(/^[^\.]|[^\.\.]$/, readdir(DIR));
closedir(DIR);
@files = sort(@files);
print "<select name=\"mySelect\">\n";
for $filename (@files)
{
print "<option value=\"" . $filename . "\">" . $filename .
"</option>\n";
}
print "</select>\n";
}
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq