[thelist] Javascript read from file challenge

rudy limeback r937 at interlog.com
Mon Jul 10 22:51:47 CDT 2000


> However, I am still wondering how I would get Javascript to read a
> file from the web server, and then populate an array with the data
> from that file for use later in the script.  Anyone have any ideas or
> is this even possible given JavaScript's built-in security features?

hi greg

gotta agree with jeff, if you can do it with a database backend, that's the
way to go

however, you *can* read a file in using javascript, provided that you don't
mind actually having javascript code in that file

for example, consider:

   addClient("Fred Flintstone");
   addClient("Barney Rubble");
   addClient("Barney Dinosaur");
   addClient("Velo C. Raptor");
   addClient("Velo Sport");
   addClient("xxxxx");
   addClient("xxxxx");
   addClient("xxxxx");
   addClient("xxxxx");
   addClient("xxxxx");

you can see where i'm going with this, this is just an external javascript
file that gets included in the page, the addClient function is defined by
another .js that you include ahead of it, and it builds the array

you can even leave a bunch of xxxxx's in there and get the array handling
function to ignore them

another predefined function might want to sort them first, etc.

now your only problem is updating the file on the server, so you have to
decide how you want to do that

if your client can handle running an ftp program to update the server .js
file, you're all set

it's not very likely they will mess this up, i mean, this was your original
concern, right?

if you don't want them ftp'ing, maybe let them add to the existing list via
a web page form, and get the form to submit an email to you with the
additions...  "one or two clients a week" shouldn't make for *too* much
drudgery on your part...   ;o)

quick and dirty, and not as good a solution as a database backend, but
still....


rudy.limeback
r937.com
evolt.org





More information about the thelist mailing list