regards
Prashant
Client-side JS can't do that. It is trivial in any server side language
though.
> Is there any way i could estimate this so that i could determine
> the size of an array to create my tables
Huh? Nothing in that makes any sense.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
In Javascript, you never have to dimension an array before you use
it. You can just do something like this:
var imgs = some code that grabs the images
var imgArray = []; / create an empty array
for (var t=0; t=imgs[t]; t++)
imgArray.push(t);
and your array will be populated
>
> In Javascript, you never have to dimension an array before you use
> it. You can just do something like this:
>
> var imgs = some code that grabs the images
> var imgArray = []; / create an empty array
>
> for (var t=0; t=imgs[t]; t++)
> imgArray.push(t);
>
> and your array will be populated
Hey, thanks for that. I was assigning new elements with:
imgArray[imgArray.length] = t;
I knew it was inefficient, just never thought to use push, I suppose. I
feel sully now.
Thanks a ton!
~A!
Um, silly. Not sully.
>> I am looking to determine the number of image files in a
>> folder so that I could create a dynamic table accordingly. For this i
>> need a method to identify the number of files in a folder.
>
>Client-side JS can't do that.
> ...
Depends on what client-side is thought to mean. Javascript running in
Windows under WSH should be able to do what is needed, and an HTA may
too.
For that environment, microsoft.public.scripting.jscript should be
better.
--
(c) John Stockton, Surrey, UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Thanks for the idea...
But could you give me an instance how I could get each image file from
a folder ?
> Thanks for the idea...
> But could you give me an instance how I could get each image file from
> a folder ?
>
Use a server-side scripting language to write the values of the files in
a given folder. What you're asking is not meant to be accomplished via
Javascript.
~A!
--
anthony at my pet programmer dot com
> prashant said:
>
>> Thanks for the idea...
>> But could you give me an instance how I could get each image file from
>> a folder ?
>>
>
> Use a server-side scripting language to write the values of the files in
> a given folder. What you're asking is not meant to be accomplished via
> Javascript.
But for Javascript as a serverside scripting language.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
I don't think this statement makes any sense.
> What you're asking is not meant to be accomplished via Javascript.
I don't think so. Furthermore, your statement as it is implies that
JavaScript (and ECMAScript implementations in general) are scripting
languages that can be used only on the client, whereas the opposite
is true.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Probably. Where is the script and where are the image files located?
> I don't think so. Furthermore, your statement as it is implies that
> JavaScript (and ECMAScript implementations in general) are scripting
> languages that can be used only on the client, whereas the opposite
> is true.
>
Such an implication was not my intent. In almost all of the questions
asked here, however, Javascript is being used on the client side, and I
was operating under the assumption that the OP was using it that way. If
I caused any confusion, then I apologize.
It is the default assumption, unless stated otherwise, that any question
referring to script is referring to client side scripting. Don't let
Thomas' pedantic behavior distract you.
I'm a little gun-shy as it is about posting, so that helps quite a bit.
Thanks, Randy.
The images should be located on a server. The javascript would be on
the client side. As Ive seen from the replies, this should be more
easily accomplished by a server side scripting. But if you have a
simple way to get the images from a folder on the server, please let
me know.
regards
prashant
There are possibilities if the server allows to list the files in the
directory and if the default index-file is absent.
I made a demo for you:
http://www.dotinternet.be/temp/test.htm
The directory is:
http://www.dotinternet.be/temp/images/
The trick is to find some filter to make sure which text can be
considered safe enough to correspond to one image. In this case, I've
chosen for 'ALT="[IMG]"'.
I don't say that this demo is the preferred way. You will have a
shorter and more solid solution when doing the job in your favourite
server-side scripting language.
--------------------------------------------------------------------
Start Code
--------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Number of images</title>
<script type="text/javascript">
var xmlhttp;
function load(url)
{
xmlhttp=null;
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
var nr = xmlhttp.responseText.split('ALT="[IMG]"');
alert( (nr.length-1) + ' images');
}
else
{
alert("Problem retrieving resource");
}
}
}
</script>
</head>
<body onload="load('images/?' + new Date().getTime());">
<p> </p>
</body>
</html>
--------------------------------------------------------------------
End Code
--------------------------------------------------------------------
In another post you wrote that script and directory can reside on
different domains. The demo above will not work then because
XMLHttpRequest is subject to the Same Origin Policy. You can use
www.ajax-cross-domain.com to overcome this problem.
Hope this helps,
--
Bart