JavaScript Menu, DHTML Menu Powered By Milonic
DEMO - Random Image Function
for use with Milonic Solutions' DHTML Menu V5
This sample page was created in reference to this thread of discussion in the "Help and Support Version 5".

The getRandomImage() function allows you to load random images into menu items.
To activate the function in the above menu, reload the page and watch the image changes.

To use the getRandomImage() function:

  1. Place the following code at the top of your menu_data.js file
    var upperLimit = 2;
    var imagePath = "";
    var baseName = "picture";
    var imageType = ".gif";
    var randomNum = Math.round(Math.random()*upperLimit);
    var fileName = imagePath + baseName + randomNum + imageType;
    return fileName;

  2. The images must have the same ending, i.e. .gif or .jpg etc. You cannot mix file types.

  3. All images used must have the same beginning name followed by a number. The numbers must be in sequence. In this example the image is .gif, named picture, so the files are named picture0.gif, picture1.gif, picture2.gif

  4. There are four parameters at the top of the function that the user can define and edit:
    1. upperLimit = how many images minus 1. In the example at the top, there are three images, so upperLimit = 2, generating random numbes from 0 through 2.

    2. imagePath = where your images are stored, up through the last / that would be in front of the image name. Leave it set to "" (blank) if the images are in the same directory as the page.

    3. baseName = the base name of your image files, up to the number. In this example the baseName = "picture"

    4. imageType = the file type of the image files; ".gif" in the example at the top (don't forget the dot!).

  5. To include the random image in a menu item, define the item like so:

  6.       aI("text=item Text;url=whatever.htm;image="+getRandomImage()+";status=whatever;");

  7. Insert menu item properties as usual. In this example, each time the page is loaded, the menu item will randomly show picture0.gif, picture1.gif, or picture2.gif.
DHTML Menu courtesy of Milonic Solutions
Download  mm_getRandomImage() sample