View Full Version : count subfolders and pass on values of array length to other page?

10-13-2005, 02:39 PM
Is it possible to let's say I have this folder structure

A (count.html)

- B





To do a JS that counts just the amount of folders that reside in subfolder B from a page(count.html) that resides at toplevel A

another similar case:

I have an array of images that displays the length of that array with photoarray.length in a page x1.html

Can I pass that value (the array length number) to a page residing at the same level x0.html (in the same folder if you will)

Any ideas?

10-13-2005, 11:36 PM
I am assuming either this is server-side javascript or is an HTA or other trusted script allowed to access the file system.
Given that, you can use Scripting.FileSystemObject to count things.
You can pass anything you want, pretty much, via the URL.

10-14-2005, 07:03 AM
about the JS:
HTA nope
client-side yes
server-side nope

why? ISP in this case: no cgi-bin or other, therefore relying client-side JS

there is only seems a way to pass variables accross pages by means of a topFrame, (maybe?) inline frame, cookies (if enabled ?), and server-side (no option here)

10-14-2005, 03:48 PM
You can pass variables in the URL.
You cannot access the server file system from client-side JS alone.

10-14-2005, 04:25 PM
I'm not sure, but I guess that you need to have in a page a variable which is the number of the picture in a given folder. This variable will help you to give a limit to an array for a dynamic circling through the pictures. Am I right?

If so, one of the methods is to use a server-side include in your page which will counts the number of the files than create a small javascript code and writes there that variable. For instance, my programmers use php language code for this stuff.

10-14-2005, 04:39 PM
That would work great, but he said there was no server-side scripting.

Personally, I wouldn't be trying to make a site if the host had no server-side scripting. Web hosts are cheap these days. Move. :D

10-14-2005, 05:13 PM
In this case the only solution is to write that variable in the page (or in an external js file whever new pictures are sent to / remove from that folder. No other way. I have tried once to build javascript aplication which must have verfied if a file really exist (for instance when creating a new element to check it's offsetWidth) but the loading process is ussualy much slower that the code's speed, so it was a failure.

10-14-2005, 06:44 PM
Thank you for all your thoughts.

- Counting folders seems impossible with only client-side JS.
- Passing variables from one page to another with JS, seems possible. Inline frame would that be a good option? would like an example if possible with inline frame

10-14-2005, 07:42 PM
Inline frame?
From parent to child:

I think most browsers let you also do: