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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

images act like buttons

Status
Not open for further replies.

wolfmah

Programmer
Oct 24, 2001
17
CA
Hi there!

I wrote down something that make images act like buttons and it work pretty well except for one thing. I can't seem to be able to specify a specific path for images so I'm force to put them in the same place as the htm file. I want to know if it's possible to determine a relative path to the image so I can put them with the rest of my images in the "images" folder. Here are the code :

<!--
var Pic = new Array

Pic[0] = 'next.jpg'
Pic[1] = 'next-over.jpg'
Pic[2] = 'next-onclick.jpg'
// list continue here...

var p = Pic.length
var preLoad = new Array()
var i = 0;

for (i = 0; i < p; i++)
{
preLoad = new Image()
preLoad.src = Pic
}

function switchImage(whichImage,imageNumber)
{
document.images[whichImage].src = preLoad[imageNumber].src
}
//-->

I tried a few things but it didn't work. If you got it, please let me know. ¦>
 
Dosn't this work ?? :

Code:
<!--
var Pic = new Array

Pic[0] = 'images/next.jpg'
Pic[1] = 'images/next-over.jpg'
Pic[2] = 'images/next-onclick.jpg'
// list continue here...

var p = Pic.length
var preLoad = new Array()
var i = 0;

for (i = 0; i < p; i++)
    {
    preLoad = new Image()
    preLoad.src = Pic
    }

function switchImage(whichImage,imageNumber)
    {
    document.images[whichImage].src = preLoad[imageNumber].src
    }
//-->
Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top