By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

HELP WITH + AND - ==> Menu tree issue

P: 1
Folks Please help this is driving me insane
The + expands but the minus fails

Error src is null or not an object

Expand|Select|Wrap|Line Numbers
  1. function Win_onLoad()
  2. {
  3.     GetNameAndLink(0);
  4. }
  5. function GetNameAndLink(pkId)
  6. {
  7.     var myMenu = eval("menuHolder" + pkId);
  8.     if(myMenu.innerHTML != "")
  9.         return;
  10.  
  11.  
  12.     var menus = xmlResponse.selectNodes("MenuItems/MenuItem");
  13.  
  14.     var table = "";
  15.  
  16.     for(i = 0; i< menus.length; i++)
  17.     {
  18.  
  19.         var itemId = menus[i].selectSingleNode("ItemId").text;
  20.         var menuTitle = menus[i].selectSingleNode("MenuTitle").text;
  21.         var menuLink = menus[i].selectSingleNode("MenuLink").text;
  22.         var hasChildren = menus[i].selectSingleNode("HasChildren").text;
  23.         var menuLevel = menus[i].selectSingleNode("MenuLevel").text;
  24.  
  25.         var menuIndent = (menuLevel - 1) * 24 + 2;
  26.  
  27.         var menuItem = "";
  28.  
  29.         if(hasChildren == "True")
  30.         {
  31.             menuItem = '<DIV id=menuIMG0 style="CURSOR: default" noWrap><IMG onMouseOver="menuOver(\'N0' + itemId + '\')" onMouseOut="menuOff(\'N0' + itemId + '\')" class=collapse id=ExpImg' + itemId + ' style="LEFT: ' + menuIndent +'px; POSITION: relative; TOP: 4px" onclick=Expando(' + itemId + ') alt="' + menuTitle +'" src="Images/plus.gif"><SPAN class=menulabel id=N0' + itemId + '  name=N0' + itemId + ' title="' + menuTitle +'" style="LEFT: ' + menuIndent +'px; POSITION: relative" onclick=Expando(' + itemId + ')  onMouseOver="menuOver(\'N0' + itemId + '\')" onMouseOut="menuOff(\'N0' + itemId + '\')" >' + menuTitle +'</SPAN></DIV>';
  32.             menuItem += '<DIV class=childContainer id=menuHolder' + itemId + ' style="DISPLAY: inline"></DIV>'
  33.         }
  34.         else
  35.         {
  36.             menuItem = '<DIV id=menuIMG0 style="CURSOR: default" noWrap><IMG onMouseOver="menuOver(\'N0' + itemId + '\')" onMouseOut="menuOff(\'N0' + itemId + '\')" class=collapse id=E0 style="LEFT: ' + menuIndent +'px; POSITION: relative; TOP: 4px" onclick="OpenItem(\'' + menuLink +'\', \'N0' + itemId + '\')" alt="' + menuTitle +'" src="Images/reporticon_big.gif"><SPAN class=menulabel id=N0' + itemId + '  name=N0' + itemId + ' title="' + menuTitle +'" style="LEFT: ' + menuIndent +'px; POSITION: relative" onclick="OpenItem(\'' + menuLink +'\', \'N0' + itemId + '\')" onMouseOver="menuOver(\'N0' + itemId + '\')" onMouseOut="menuOff(\'N0' + itemId + '\')" >' + menuTitle +'</SPAN></DIV>';
  37.  
  38.         }
  39.  
  40.         table += menuItem;
  41.     }
  42.  
  43.     myMenu.innerHTML = table;
  44. }
  45.  
  46. function OpenItem(menuLink, menuItem)
  47. {
  48.     if(selectedId != "")
  49.     {
  50.         document.getElementsByName(selectedId)[0].className='menulabel';
  51.     }
  52.     selectedId = menuItem;
  53.     document.getElementsByName(selectedId)[0].className='menulabelon';
  54.  
  55.     //parent.main.navigate(menuLink);
  56.     parent.frames["main"].location = menuLink;
  57. }
  58.  
  59. function Expando(itemId)
  60. {
  61.     var menuImage = eval("ExpImg" + itemId);
  62.     var childDiv = eval("menuHolder" + itemId);
  63.  
  64.     if(menuImage.src.indexOf('plus') > 0)
  65.     {
  66.         menuImage.src = "Images/minus.gif";
  67.         childDiv.style.display = "";
  68.         GetNameAndLink(itemId);
  69.     }
  70.     else
  71.     {
  72.         menuImage.src = "Images/plus.gif";
  73.         childDiv.style.display = "none";
  74.     }
  75. }
  76.  
  77. function menuOver(menuItem)
  78. {
  79.  
  80.     var oWorkItem;
  81.     oWorkItem = menuItem;
  82.  
  83.     document.getElementsByName(oWorkItem)[0].className='menulabelon';
  84.  
  85. }
  86.  
  87.  
  88. function menuOff(menuItem)
  89. {
  90.     var oWorkItem
  91.     oWorkItem = menuItem
  92.  
  93.      if (document.getElementsByName(oWorkItem)[0].className == "menulabelon" && oWorkItem != selectedId)
  94.      {
  95.          document.getElementsByName(oWorkItem)[0].className='menulabel';
  96.      }
  97.  
  98. }
  99.  
  100.  
  101. </script>
  102. </head>
  103. <BODY topmargin="0" leftmargin="0" style="OVERFLOW: auto;border-right: solid 1px black" bgcolor="#FAFAFF"  onLoad="Win_onLoad()" onhelp="OpenTrackerHelpFromOtherFrames(); return false;">
  104. <table border="0" height="24" width="100%" cellpadding="0" cellspacing="0">
  105.     <tr style="height: 25px">
  106.         <td class="filterHead" id="tdTitle" width="100%" style='padding-left:5px;font-weight:bold;'>
  107.             TrackerSuite.Net
  108.         </td>
  109.     </tr>
  110. </table>
  111. <table width="100%" border="0" cellpadding="0" cellspacing="0" class="filterUpperBorder" >
  112.     <tr style="height: 1px">
  113.         <td><img src="http://bytes.com/images/1.gif" width="1" height="1"></td>
  114.     </tr>
  115. </table>
  116. <DIV id=menulabels style="padding-left:8px;padding-top:2px;">
  117.  
  118. <div id="menuHolder0" name="menuHolder0"></div>
  119.  
  120. </div><DIV id=mylabels style="padding-left:8px;padding-top:2px;"></DIV>
  121. <!--<OBJECT id=CookieScriptlet style="LEFT: 0px; TOP: 0px" type=text/x-scriptlet height=0
  122.     width=0 data=CookieManager.htm></OBJECT>-->
  123. </BODY>
  124. </HTML>
Apr 27 '09 #1
Share this Question
Share on Google+
2 Replies


RamananKalirajan
100+
P: 607
Can u please attach the necessary files (Images) for this. xmlResponse is null here.

Regards
Ramanan Kalirajan
Apr 28 '09 #2

acoder
Expert Mod 15k+
P: 16,027
On line 7, you have
Expand|Select|Wrap|Line Numbers
  1. var myMenu = eval("menuHolder" + pkId);
Although this will not cause a problem in IE, it would in other browsers, so change it to:
Expand|Select|Wrap|Line Numbers
  1. var myMenu = document.getElementById("menuHolder" + pkId);
The error message suggests that it's not getting the correct object. At least provide the response (xmlResponse), so that the code is easy to test, or a link.
Apr 28 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.