Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load an Array from directory or db...

Status
Not open for further replies.

jgraves13

Programmer
Jan 31, 2007
42
0
0
US
I am not sure how to pull data i.e.(images) from an image directory. I have a rotate function that I am currently using in my Body OnLoad tag. I want to make my life easier by just randomly grabing images instead of me having to type in what images display randomly.

I am also open to using a database to load the array if anyone would like to address that as well.

Thanks in advance.
JG
 
If you're using a DB then chances are you have server-side scripting available to you.

This being the case, you should ask in the forum for whatever server-side scripting you are using (JSP, PHP, CGI, etc) to determine how to read a list of files in a directory, and populate your array that way.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
So are you saying that JavaScript can not populate an array from a directory or database? I am looking for either method to populate my array.

I already have a a JavaScript that does an image flip every 30 seconds, I would like to just enhance it a little more. Any other thoughts?
 
So are you saying that JavaScript can not populate an array from a directory or database?

With ActiveX you can, but I feel dirty even mentioning it. You're really gonna be better off using a server side language.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
So are you saying that JavaScript can not populate an array from a directory or database?

Well that depends, really.

If you're after a list of files on the server, then you'll have to do it using server-side scripting, as client-side JS will have no access to the server's directory structure.

If you're after a list of files on the user's PC, then you'd have to use JS, which would restrict you to using ActiveX in IE, or some Java File IO in Fx (and any other supporting browser).

given you'd not said where you wanted the images from, I took a guess, and gave you what I thought to be the most appropriate answer.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRayPreachersSon and kaht,

Thank you both for you time and answers. I just thought it was possible to do it quick and dirty (so to speak). BillyRayPreachersSon you did give me the correct answer now that I look back at it and see what your saying. That just wasn't what I really wanted to hear at the moment... I am sorry if I came off the wrong way. I do appologize... I will look at PHP to solve my dilemma...

Thank you,
JG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top