Solved

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

Posted on 2008-06-12
5
339 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now