I have a page that list tiems a user can add to a shipping list (cookie based). In my javascript code, I have this, which actually changes text on my page from Add to Shopping List to Remove From shopping List:
[code]
function Item(i,e) {
if(document.getElementById(e).firstChild.firstChild.data==’Add to shopping list’) {
document.getElementById(e).firstChild.firstChild.data=’Remove from shopping list’;
document.getElementById(e).firstChild.setAttribute(“title”,”Remove from shopping list”);
addItem(i);
return true;
} else {
document.getElementById(e).firstChild.firstChild.data=’Add to shopping list’;
document.getElementById(e).firstChild.setAttribute(“title”,”Add to shopping list”);
removeItem(i);
return true;
}
}
I need to change this so that it actually changes an image now, instead of text. How would I do this? I tried replacing the text string with the path to my images, but that did not do anything, like this;
[code]
function Item(i,e) {
alert(“called script”);
if(document.getElementById(e).firstChild.firstChild.data==’/images/btn_add_shopping_list.png’) {
alert(“adding to shoppinglist”);
document.getElementById(e).firstChild.firstChild.data=’/images/btn_remove_shopping_list.png’;
document.getElementById(e).firstChild.setAttribute(“title”,”Remove from shopping list”);
addItem(i);
return true;
} else {
document.getElementById(e).firstChild.firstChild.data=’Add to shopping list’;
document.getElementById(e).firstChild.setAttribute(“title”,”Add to shopping list”);
removeItem(i);
return true;
}
}
I get the first alert, but not the second.
Thanks in advance!!!