habib
10-07-2002, 11:35 AM
Hi,
I am trying to change an image depending on the cookie value of a user. The image is of a table which contains cost amounts in various currencies.
Below is my function which is stored in an external.js file (image.js)
function change_image() {
var name='home_location';
var picture="";
var cookieVal=getCookie(name);
if (getCookie('home_location') == 'EU') {
picture="<img src=images/costs-eu.jpg>"; }
else
if (getCookie('home_location') == 'SA') {
picture="<img src=images/costs-sa.jpg>"; }
else
if (getCookie('home_location') == 'UK') {
picture="<img src=images/costs-uk.jpg>"; }
else
if (getCookie('home_location') == 'US') {
picture="<img src=images/costs-us.jpg>";
}
}
I then call this function in my htm file
<head>
<script type="text/javascript" src="script/image.js"></script>
</head>
<body onLoad="change_image();">
<script>document.write(picture);</script>
</body>
But I keep getting "picture" undefined errors
Can't understand why, can anyone help?
Thanks
HR
I am trying to change an image depending on the cookie value of a user. The image is of a table which contains cost amounts in various currencies.
Below is my function which is stored in an external.js file (image.js)
function change_image() {
var name='home_location';
var picture="";
var cookieVal=getCookie(name);
if (getCookie('home_location') == 'EU') {
picture="<img src=images/costs-eu.jpg>"; }
else
if (getCookie('home_location') == 'SA') {
picture="<img src=images/costs-sa.jpg>"; }
else
if (getCookie('home_location') == 'UK') {
picture="<img src=images/costs-uk.jpg>"; }
else
if (getCookie('home_location') == 'US') {
picture="<img src=images/costs-us.jpg>";
}
}
I then call this function in my htm file
<head>
<script type="text/javascript" src="script/image.js"></script>
</head>
<body onLoad="change_image();">
<script>document.write(picture);</script>
</body>
But I keep getting "picture" undefined errors
Can't understand why, can anyone help?
Thanks
HR