Thread: JavaScript Help
View Single Post
Old 05-23-07, 11:12 PM   #3
Ngemu Mod
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: JavaScript Help

document.getElementById(div_id).style.backgroundImage = 'url(btn_path)';
You're treating the javascript variable name as a string. It will not evaluate to a variable this way, but into the actual string: "url(btn_path)". And the CSS attribute would be:

background-image: url(btn_path);
Replace with:

document.getElementById(div_id).style.backgroundImage = 'url("'+btn_path+'")';
Since it's concantenated, the javascript variable remains a variable with the appropriate value and the whole string evaluates correctly.
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w]

Last edited by fivefeet8; 05-25-07 at 11:02 AM.
fivefeet8 is offline   Reply With Quote