Solved

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

Posted on 2008-06-12
5
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

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…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

738 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