Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

24 Experts available now in Live!

Get 1:1 Help Now