Solved

How do i display an image in Javascript using a wildcard for the image name?

Posted on 2008-06-12
5
345 Views
Last Modified: 2012-05-05
Hello,

I want to display an image in Javascript from a folder which is named after a record 'id' and the name of the image is prefixed by X_

I have made the following guess as to what this might be - please can you correct?
<img src="travel_pics/" + id + "/X_*.jpg" width=150 height=100>


Many thanks
0
Comment
Question by:Daniish
  • 3
  • 2
5 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 21767217
If there are more then one files that match the wild card then which file should the browser display?
0
 

Author Comment

by:Daniish
ID: 21767236
I will ensure that there is only ever 1 file that is prefixed X_ in each folder.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21768111
Sorry but even then, JavaScript cannot look at web server side file system.
Browser is allowed only to ask for one file and gets that one files as response.

You have to script that on web server side by ASP, PHP or whatever scripting you use on server side.

0
 

Author Comment

by:Daniish
ID: 21768361
It shouldn't need to look at the web server side file system - because the filename is composed of attributes already available in my PHP script - namely the 'id' that are alredy being displayed on my site...

Really all i'm asking is how to use a wildcard in a filename:

"/X_*.jpg"

whether that be
"\X_" . * . ".jpg" - will the asterix work here ?
0
 

Accepted Solution

by:
Daniish earned 0 total points
ID: 21769000
My bad!

Since there is only ever going to be one image in a folder that is prefixed X_ i may as well give the image a complete name e.g. XXX.jpg and do the same for all folders, that way there's no need for a wildcard anyway.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question