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

Problems with insertItem and mm_removeItem


Poster: mumr
Dated: Monday January 10 2005 - 1:11:36 GMT

Hi Guys,
I am having some problems with insertItem and removeItem after the drawMenus() has been called

I checked this thread but it didn't help...
http://www.milonic.com/forum/viewtopic. ... insertitem

1)When the insertItem is called within a function...then style is not carried to the new item....
eg:
Working:
<script>
main.insertItem("text=New Menu item Added;",3)
</script>

Not working:
<script>
function addItem(){
main.insertItem("text=New Menu item Added;",3)
}
</script>

2)Remove item is not removing the item from the list...its hiding...So next time when i add the same item...its showing twice....

I am very happy with the way the menu is working...other than the above 2problems...

I wanted to buy the menu but i can't buy until i have these two problems fixed...

Any help would be much appreciated.


Poster: Ruth
Dated: Monday January 10 2005 - 4:00:49 GMT

I think you might need to be more specific as to what you are doing, i.e. put in your function and the menu_data.js file showing how you have it set up so those familiar with functions can take a look.

As for the remove item. That is a function which was done here in the forum, and as Kevin noted it does not remove the item, it only masks it. It's not a Milonic designed function/module of the menu.

Ruth


Poster: mumr
Dated: Monday January 10 2005 - 4:19:18 GMT

Hi Ruth,
Ruth wrote:
I think you might need to be more specific as to what you are doing, i.e. put in your function and the menu_data.js file showing how you have it set up so those familiar with functions can take a look.


Code:
//my function
function add_item(){
   // Add new menu items before they are commited.
   // The text you use here is the same as the text you would use in the aI() string.
   main.insertItem("text=New Menu item Added;",3)
   partners.insertItem("text=New Partner Added;offcolor=white;offbgcolor=darkblue;decoration=underline",2);
   partners.insertItem("text=Another New Partner Added;offcolor=yellow;offbgcolor=red;decoration=line-through",4);
}

html which calls add_item()
<a href='javascript:add_item()'>click to add "New Item" to "Partners" menu</a>
   
Here's the js file insertitem_menu_data.js

_menuCloseDelay=500           // The time delay for menus to remain visible on mouse out
_menuOpenDelay=150            // The time delay before menus open on mouse over
_subOffsetTop=10              // Sub menu top offset
_subOffsetLeft=-10            // Sub menu left offset

with(menuStyle=new mm_style()){
onbgcolor="#4F8EB6";
oncolor="#ffffff";
offbgcolor="#DCE9F0";
offcolor="#515151";
bordercolor="#296488";
borderstyle="solid";
borderwidth=1;
separatorcolor="#2D729D";
separatorsize="1";
padding=5;
fontsize="75%";
fontstyle="normal";
fontfamily="Verdana, Tahoma, Arial";
pagecolor="black";
pagebgcolor="#82B6D7";
headercolor="#000000";
headerbgcolor="#ffffff";
subimage="arrow.gif";
subimagepadding="2";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color='#777777', Direction=135, Strength=5)";
outfilter="randomdissolve(duration=0.3)";
}


with(main=new menuname("Main Menu")){
style=menuStyle;
top=200;
left=100;
alwaysvisible=1;
aI("text=Home;url=http://www.milonic.dev/;status=Back To Home Page;");
aI("text=Menu Samples;showmenu=Samples;");
aI("text=Milonic;showmenu=Milonic;");
aI("text=Partners;showmenu=Partners;");
aI("text=Links;showmenu=Links;");
aI("text=My Milonic;showmenu=MyMilonic;");
}



with(new menuname("Samples")){
style=menuStyle;
overflow="scroll";
aI("text=Black Forest;url=/menusample34.php;");
aI("text=Clean;url=/menusample29.php;");
aI("text=Agriculture;url=/menusample33.php;");
aI("text=Breeze;url=/menusample32.php;");
aI("text=Bracket;url=/menusample35.php;");
aI("text=Bronze Bar;url=/menusample36.php;");
aI("text=Candy;url=/menusample37.php;");
aI("text=Chocolate;url=/menusample38.php;");
aI("text=Circus;url=/menusample39.php;");
aI("text=Coloured Squares;url=/menusample40.php;");
aI("text=Corporation;url=/menusample41.php;");
aI("text=Cosmetic;url=/menusample42.php;");
aI("text=Discreet;url=/menusample43.php;");
aI("text=CSquared;url=/menusample44.php;");
aI("text=New Sample Menu project;url=/menusample45.php;");
aI("text=Horizontal Navigational Menu;url=/menusample1.php;onfunction=showtip('The most common of menu samples. Thissample allows for vertical pulldown menusto appear from a horizontal main menu');");
aI("text=Vertical Navigational Menu;url=/menusample2.php;onfunction=showtip('Another common sample This time, the submenus are opened from a vertical main menu');");
aI("text=All Horizontal Menus;url=/menusample25.php;onfunction=showtip('If space is limited, this menu sample shows howto open sub-menus in a horizontal orientation');");
aI("text=Using The Popup Menu Function Fixed Position;url=/menusample3.php;onfunction=showtip('The popup function is a built in featureallowing menus to opened based on mouseactions from other HTML objects');");
aI("text=Using The Popup Menu Function Positioned by Images;url=/menusample24.php;onfunction=showtip('The popup function can also open menusbased on mouse action but also positionedrelative to an image');");
aI("text=Image Map Sample;url=/menusample4.php;onfunction=showtip('Image maps can be used to open menus using the popupfunction based on the HTML object AREA');");
aI("text=Multiple Styles;url=/menusample5.php;onfunction=showtip('Demonstrating how to declare properties using differentmenu styles. Separate styles can be declared for eachmenu ora style can be used globally for every menu');");
aI("text=Menus and Tool Tips;url=/menusample6.php;onfunction=showtip('Tooltips are a handy way of adding more informationinforming the user how to navigate your website oruse your application incorporating the menu');");
aI("text=Multiple Colored Menus;url=/menusample7.php;onfunction=showtip('');");
aI("text=Menu Items as Headers;url=/menusample8.php;onfunction=showtip('If yo uneed to separate blocks of menu items withina single menu, Headers are a handy way ofsegragating your menu items');");
aI("text=Windows XP Style Menus;url=/menusample12.php;onfunction=showtip('If you like the look of the Microsoft Widows XP menus,these can be replicated using the menu and a few images');");
aI("text=Windows 98 Style Menus;url=/menusample13.php;onfunction=showtip('The Microfost Windows 98 3D look & feel can beacheived by adding high and low 3D colors toyour menu styles');");
aI("text=Relative Positioning (Table Bound);url=/menusample9.php;onfunction=showtip('Positioning menus relative to your web pagesflow can be acheived by setting the menu styleproperty position to relative');");
aI("text=Follow Scrolling;url=/menusample10.php;onfunction=showtip('Keeping the menu available at all times no matterwhere your user has scrolled to, can be acheived bysetting the followscroll property for your main menu');");
aI("text=Opening Windows & Frames;url=/menusample11.php;onfunction=showtip('Opening links in other windows or other framesis easy by using the target menu item property.');");
aI("text=Hiding DIVs when displaying menus;url=/menusample14.php;onfunction=showtip('Older browsers have a problem with form objectsand other HTML objects that naturally sit higher inthe browser layer hiding the menu.The workaround fr this is to use DIV hiding');");
aI("text=Activating MouseOver & MouseOut Functions;url=/menusample15.php;onfunction=showtip('onfunction, offfunction and clickfunction arebuilt in features that allow you to addcustom JavaScript to several menu events');");
aI("text=Dynamic Dragable Menus;url=/menusample22.php;onfunction=showtip('By setting your menus type to be draggablethis will allow for your users to movemain menus by drag and drop');");
aI("text=Positioning with screenposition & offsets;url=/menusample23.php;onfunction=showtip('Setting the position of menus using screenpositionis a handy way of ensuring that your menus willalways be centered or positioned exactly howyou need');");
aI("text=100% Width Span Menu;url=/menusample26.php;onfunction=showtip('Spanning the menu to 100% of the browser widthwill allow for the menu to become a page separator');");
aI("text=Context Right Click Menu;url=/menusample27.php;onfunction=showtip('Context menus are easily configured with theMilonic DHTML Menu. No special requirements are neededExcept for a small custom JavaScript module');");
aI("text=Static Images Sample;url=/menusample16.php;onfunction=showtip('Inserting images inside menus is made easywith the use of the image property for menu items');");
aI("text=Rollover/swap Images;url=/menusample17.php;onfunction=showtip('Swaping images on mouse over can be acheivedby setting the image and onimage propertiesfor your menu items');");
aI("text=Menus built from images;url=/menusample18.php;onfunction=showtip('If you prefer to build your menus completelyfrom images this is easily possible, letthe menu take care of your images.');");
aI("text=Images as Menu Backgrounds;url=/menusample19.php;onfunction=showtip('Adding a background image to your menus can vastly improve the apperance of otherwise dullbackgrounds.');");
aI("text=Background Menu Item Images;url=/menusample20.php;onfunction=showtip('Each menu item can have its own background image.Text can be overlaid meaning you only need to buildand download one image');");
}

with(new menuname("Milonic")){
style=menuStyle;
aI("text=Product Purchasing Page;url=http://www.milonic.dev/cbuy.php;");
aI("text=Contact Us;url=http://www.milonic.dev/contactus.php;");
aI("text=Newsletter Subscription;url=http://www.milonic.dev/newsletter.php;");
aI("text=FAQ;url=http://www.milonic.dev/menufaq.php;");
aI("text=Discussion Forum;url=http://www.milonic.dev/forum/;");
aI("text=Software License Agreement;url=http://www.milonic.dev/license.php;");
aI("text=Privacy Policy;url=http://www.milonic.dev/privacy.php;");
}

with(partners=new menuname("Partners")){
style=menuStyle;
aI("text=(aq) Web Hosting;url=http://www.a-q.co.uk/;status=(aq) Web Server Hosting & Services;");
aI("text=WebSmith;url=websmith;");
aI("text=SMS 2 Email;url=http://www.sms2email.com/;");
}

with(new menuname("Links")){
style=menuStyle;
aI("text=Apache Web Server;url=http://www.apache.org/;status=Apache Web Server, the basis of Milonic's Web Site;");
aI("text=MySQL Database Server;url=http://ww.mysql.com/;status=MySQL, Milonic's Prefered Choice of Database Server;");
aI("text=PHP - Development;url=http://www.php.net/;status=PHP - Web Server Scripting as used by Milonic;");
aI("text=phpBB Web Forum System;url=http://www.phpbb.net/;status=PHP Based Web Forum, Milonic's Recommended Forum Software;");
aI("text=Anti Spam Tools;showmenu=Anti Spam;status=Anti Spam Solutions, as used by Milonic;");
}

with(new menuname("Anti Spam")){
style=menuStyle;
aI("text=Spam Cop;url=http://www.spamcop.net/;");
aI("text=Mime Defang;url=http://www.mimedefang.org/;");
aI("text=Spam Assassin;url=http://www.spamassassin.org/;");
}

with(new menuname("MyMilonic")){
style=menuStyle;
aI("text=Login;url=http://www.milonic.dev/login.php;");
aI("text=Licenses;url=http://www.milonic.dev/mylicenses.php;");
aI("text=Invoices;url=http://www.milonic.dev/myinvoices.php;");
aI("text=Make Support Request;url=http://www.milonic.dev/reqsupport.php;");
aI("text=View Support Requests;url=http://www.milonic.dev/mysupport.php;");
aI("text=Your Details;url=http://www.milonic.dev/mydetails.php;");
}

drawMenus();  // Commit the menus to the page
.

Ruth wrote:
As for the remove item. That is a function which was done here in the forum, and as Kevin noted it does not remove the item, it only masks it. It's not a Milonic designed function/module of the menu.

ok....

Hope that helps


Poster: Ruth
Dated: Monday January 10 2005 - 17:31:57 GMT

mumr wrote:
I checked this thread but it didn't help...
http://www.milonic.com/forum/viewtopic. ... insertitem


I don't think you read far enough. From that thread:
kevin3442 wrote:
instead... (2) You can slightly modify the insertItem() function itself. I wouldn't normally want to mess around directly with Andy's code because... well, it isn't mine. But it seems much easier this way, so...

The insertitem.js file contains the insertItem() function. If you add the following line:
Code:
BDMenu(_mi[_inum][0]);

as the last line in the inserItem() function definition (i.e., before the closing } curly brace), that should do it.

This will work if you only intend to use insertItem() after the initial menus are rendered with drawMenus()... as is your intent I believe. If you try to use the mod before drawMenus(), as in Andy's sample, then you'll get errors and your menus probably won't appear at all....
Kevin


I played with this and did get it to work. You need to add the code Kevin gave. This is the last lines of the insertitem.js module
Code:
_m[_mn][6]=_oStyle
}
menuname.prototype.insertItem=_iI;

You need to change that to:
Code:
_m[_mn][6]=_oStyle;
   BDMenu(_mi[_inum][0]);
}
menuname.prototype.insertItem=_iI;


Code:
<a href='javascript:partners.insertItem("padding=3;fontweight=bold;separatorsize=1;separatorcolor=#000000;text=New Item;url=http://www.whatever.com/;",2)'>click to add "New Item" to "Partners" menu</a>
This is the html I used. It adds an item in the 3rd place of the partners menu. The 2 tells it the item to place the new item after. Note that I put in style codes BEFORE I put in the text. Because this is adding the item after the menu is rendered, it doesn't get to read the style codes, they are already rendered, so it seems if you put the style before you put the text to be rendered it reads that and adds it to the item.

You might want to go to that other thread and copy Kevin's reply so you have it in full.

As to the remove item, since it is only hiding the item, perhaps you might ask in the other post if there is a way to have it 'unhide' when clicked a second time.
Hope that helps.

Ruth