Hi guys,
I have a DHTML menu, and on the menu there is a functionality that one child is right-clicked, a user is given a choice to add this child (a program description) to a database. This is the code:
[code=php]
// menu item
<li><a href=”blah.jsp” title=”Program1″><span name=”Program1″ oncontextmenu=”javascript:addToFavorites(this);return false;”>Program1</span></a></li>
//addToFavorites
var favoriteObject;
function addToFavorites(obj){
favoriteObject = obj.name;
showHide(‘addToFavoritesLayer’,’visible’);
showHide(‘KWILogoLayer’,’hidden’);
}
Now, in the layer addToFavoritesLayer, I have a document.write for favoriteObject:
[code=php]
<td align=”center” valign=”middle” colspan=”2″ class=”favoritesMsg”>Add <script>document.write(favoriteObject);</script> to Favorites?</td>
The problem is that after addToFavorites() is called, and addToFavoritesLayer is made visible, document.write(favoriteObject) is coming in as undefined. In layer I have a link that calls getObject() function:
[code=php]
function getObject(){
showHide(‘addToFavoritesLayer’,’hidden’);
showHide(‘KWILogoLayer’,’visible’);
addFavItem(favoriteObject);
}
function addFavItem(item){
document.getElementById(‘favList’).src=”favorites/addToFavorites.jsp?item=” + encodeURL(item);
showHide(‘Favorites’,’visible’);
}
and that works fine, so how come with document.write() I have a problem?
thanks,
camokat