Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a simple script involving images

Status
Not open for further replies.

Delameko

Programmer
Oct 14, 2003
37
GB
I won't bore you with all the details, but I'm working on a site thats updating dynamically from an XML.

In the XML there's no reference to images (as its from an outside source) so I've decided to use the ID code thats with each entry to dynamically select which image to use. The HTML/XSLT currently looks like this:
Code:
<img src="images/{$ID}.jpg" />

The problem is that if the XML is updated with a new entry there's no image file to match the ID until someone adds one.

So what I need to do (I'm not very good at writing JavaScript) is to have a little script that says:
Code:
"if images/{$ID}.jpg exists use it, otherwise use images/Default.jpg"

It seems like it should be easy, but I'm just not sure what objects i should be using etc.

Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top