View Full Version : Calling an image with Jscript
Zapcat
09-27-2002, 01:27 PM
I'm trying to call an image using Jscript, and to keep things tidy want to keep them in a seperate folder. Part of the image name is a variable, and this is where things are falling over. An example of my code is below. Where am I going wrong??
borderPic.src = "\images\" + myBorder + " border.gif";
ZapCat
:confused:
chrismiceli
09-27-2002, 01:30 PM
i think this might be it
borderPic.src = "\images\" + myBorder + " border.gif";
why do you have a space between the word border and the quote before it?? and if that isn't the problem what is the variable myBorder?
Spookster
09-27-2002, 02:15 PM
Are you using Jscript or Javascript?
Zapcat
09-27-2002, 03:28 PM
I am using Javascript.
The name of one of the gifs will be "red border" which is why the gap.
ZapCat
:confused:
adios
09-27-2002, 04:16 PM
Zapcat...
Just building strings here. Post the end result desired (file path) and any string you'll be passing in in a variable.
japangreg
09-27-2002, 04:34 PM
Hey, Zapcat.
I'm kinda new to JavaScript, but I think I know what might be wrong. The foreslashes; I think you need to use a backslash as well.
So:
borderPic.src = "\images\" + myBorder + "border.gif";
becomes
borderPic.src = "/\images/\" + myBorder + "border.gif";
Just a guess, but that's what I had to do...
hth
japangreg
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.