This sample demo was created in reference to this thread in the Help and Support for Version 5
The function.
This function applies to the properties of items, i.e. onbgcolor, offbgcolor, url, decoration, font, text, type, etc. It will find the item you list and change the property you have specified for that item.
function mm_changeItemProperty(menuName, itemName, codeRef, newValue, updateDisplay)
{
menuName = menuName.toLowerCase();
for (i=0; i<_mi.length; i++)
if (_mi[i][1].replace(/\ \;/ig,' ') == itemName && _m[_mi[i][0]][1] == menuName) break;
if (i == _mi.length) return;
_mi[i][codeRef] = newValue;
if (updateDisplay) BDMenu(_mi[i][0]);
}
The parameters.
mm_changeItemProperty() is the function name. It takes five [5] parameters.- menuName is the name of the menu which contains the item you want to change [name you give the menu i.e. Main etc.] It is not case sensitive.
- itemName the function uses the text that appears in the menu item itself, [the text= property of the aI() i.e. Home, etc.] It is case sensitive, so it must be exactly as it appears
- codeRef is the index inside the menu program for the property that you want to change i.e offbgcolor code reference is 7, text is 1, etc. You can find the codeRef in the Menu Quick Reference Guide menu item properties.
- newValue is the new value that you want to assign to the identified menu item property, for the targeted menu item. This might be a numeric or a string value, depending on what type of property you are changing (a color or URL would be a string, widths would be numeric).
- updateDisplay is a boolean indicating that you do (true) or do not (false) want to force an immediate update for display purposes. You'd typically want to use true for visual properties, like color or size, especially if the menu is already visible when you make the change. You could use false for "behavioral" properties, like openonclick or the URL, things that won't be used until the next time the item is moused over or clicked (using true for these shouldn't hurt, but would cause an additional, probably unnecessary function call which would add to the time necessary to build the menu).
Demo - Dynamic Drag
Instructions
- Download the dragdrop.js module not included in the sample.
- Download the dynamic drag sample and open the dynamic_drag_data.js file.
- Create your own style with the desired colors, fonts etc.
- Do NOT modify the first or last item except for the onbgcolor, offbgcolor, offcolor, oncolor of the first item which you can change to match your style colors.
These two items are an integral part of the functions.
For example, if you changed Drag Mode: <b>Off</b> in item 1 to something else, the function would be looking for Drag Mode: <b>Off</b>:
mm_changeItemProperty('main','Drag Mode: Off',86,true,0);
Not finding the words specified in the function, it will not work. - Add your own items [in between the first and last ones, and your own submenus.
- Call the file as you would any menu_data.js file.
More Demos
These demos have been created placing the function directly on the web page. Placing the function on a page limits the change to that page.