Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:57

Delete everything from menuitem array


Poster: qperkins
Dated: Wednesday January 19 2005 - 5:01:23 GMT

I know that the ability to remove items from a menu dynamically after the menu is loaded is on the feature request list, and that the hide a menu item will not work for me.

I don't suppose anyone knows which array I could nuke (length=0?) to remove all of the items from a menu? I could then add items back in using the insertitem dynamically as I need them. I was trying to modify the insertitems script, but quickly found that I was over my head. Basically, I'd love a similar script that would allow me to call menuname.nuke() and it would remove all items from that particular menu array. I could then use the excellent insertitem to repopulate it. (Never would it remain empty).

Any ideas?


Poster: Andy
Dated: Wednesday January 19 2005 - 10:37:52 GMT

Here is a beta of a function that will remove a menu item from an already built menu:

I'm now working on the insertItem funciton - Could have sworn I'd already written this but cannot seemto find a reference to it anywhere. Please let me know where it is if you can find it.

Cheers
Andy


Code:
function mm_deleteItem(_mN, _iN)
{
   _mnu=getMenuByName(_mN)
   _ii=_m[_mnu][0][_iN-1]
   _tA=_nA()
   for(_r=0;_r<_mi.length;_r++)
   {
      if(_r!=_ii)_tA[_tA.length]=_mi[_r]
   }
   _mi=_tA
   _tA=_nA()
   
   _cnt=0;
   for(_r=0;_r<_m[_mnu][0].length;_r++)
   {   
      if(_m[_mnu][0][_r]!=_ii)
      {
         _tA[_tA.length]=_m[_mnu][0][_cnt]
         _cnt++
      }
   }
   _m[_mnu][0]=_tA   
   
   
   for(_r=_mnu+1;_r<_m.length;_r++)
   {
      for(_p=0;_p<_m[_r][0].length;_p++)
      {
         _m[_r][0][_p]--
      }
   }
      
   for(_r=0;_r<_m.length;_r++)
   {
      _m[_r][23]=0
      _gm=gmobj("menu"+_r)   
      if(_m[_r][7])
      {
         _gm.innerHTML=_drawMenu(_r)
      }
      else
      {
         _gm.innerHTML=""
         _fixMenu(_mnu)
      }
   }
}


Syntax is mm_deleteItem('MENUNAME', ITEMNUMBER)

ie, mm_deleteItem('Main Menu', 3) will delete the third item in the main menu

-- Andy


Poster: Andy
Dated: Wednesday January 19 2005 - 13:29:28 GMT

Just developed a module for editing menu items, it's at

http://www.milonic.com/mm_menueditapi.js

Hope this helps
Andy


Poster: Streetwise
Dated: Wednesday January 19 2005 - 15:06:09 GMT

(showing my ignorance here)

How does one use this code to remove items? Do I put it in a new page? If I have to ask, I probably shouldn't be thinking about using it :P

Dave

Thanks so much, but...


Poster: qperkins
Dated: Wednesday January 19 2005 - 17:47:57 GMT

I really appreciate you sharing the remove script and I have several areas I can immediately use it!

However, I was wondering if there was an easy way to accomplish my original task of erasing all of the items from a particular menu. Or, alternately I could use the remove script your provided if there was a way to query how many items there were in a particular menu (the length of the appropriate array?)

Thanks for your help!

Re: Delete everything from menuitem array


Poster: suraina
Dated: Monday February 11 2008 - 9:54:41 GMT

Hi Andy

I tried to use mm_deleteItem () and other functions given in the mm_menueditapi.js mentioned above ...
but every time i get a JS error

object expected referencing to mmenudom.js
In my code i have also included milonic_src.js


Sunny