I have been trialling your DHTML Menu and so far it has everything I'm looking for and more and is working brilliantly. Unfortunately however I've just discovered that one of my other scripts is now no longer working. The script is..
function expand(el) {
el2=eval(el)
if(el2.style.display == "none"){
el2.style.display="";
el2.expanded=true;
}
else {
el2.style.display="none";
el2.expanded=false;
}
}
and it expands or hides a div layer which is defined for example as...
<div id="alertbodyPaid style="display:none">
..a table with info etc usually here...
</div>
and is called via an href ..
<a href="##" class="green" target="_self" onClick="expand('alertbodyPaid'); return false" >Click Here to view</a>
I am now getting the following error message when clicking on the Href..
"Object doesn't support this property or message"
This is something I use quite frequently throughout the site and I need them to be able to work together. Although I'm able to write some basic javascript functions this is beyond my level of knowledge. It is something that seems to happen when the DHTML Menu is actually drawn. If I remove the drawmenu command there is no problem. I'm thinking that perhaps the default style properties have been changes in some way. Can you please help ...
Thanks
Gayle
Problem with style references in existing javascript code
Hi Gayle,
el2 is used internally by the menu system to refer to a menu item (e.g., element 2). Your function sets el2=eval(el). Since el2 isn't declared within the function, it won't be treated as a local variable (i.e., local to that function) if a global variable of the same name already exists. Since an el2 already existed globally, your function was assigning to the global el2, instead of a variable within your function. I'm betting that the conflict also screwed up part of the menu.
Anyway, changing the variable name in the function removed the conflict. You could probably also have resolved the conflict by declaring el2 locally, inside of the function. I.e., instead of el2=eval(el) you could have put var el2=eval(el). This would make a local el2 for use inside the function, but cut off access to the global el2 from within the function (which wouldn't have been a problem anyway).
So... you asked
Kevin
el2 is used internally by the menu system to refer to a menu item (e.g., element 2). Your function sets el2=eval(el). Since el2 isn't declared within the function, it won't be treated as a local variable (i.e., local to that function) if a global variable of the same name already exists. Since an el2 already existed globally, your function was assigning to the global el2, instead of a variable within your function. I'm betting that the conflict also screwed up part of the menu.
Anyway, changing the variable name in the function removed the conflict. You could probably also have resolved the conflict by declaring el2 locally, inside of the function. I.e., instead of el2=eval(el) you could have put var el2=eval(el). This would make a local el2 for use inside the function, but cut off access to the global el2 from within the function (which wouldn't have been a problem anyway).
So... you asked

Kevin