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:50

Multiple Dynamic Menus on a Single Page


Poster: dmcquade
Dated: Friday October 27 2006 - 18:31:36 BST

Hello everyone!

I'm trying to see if I can find a menu tool that will allow multiple dynamic menus on a single page. In a nutshell, I have a page that returns a recordset using ASP / VB. I want to create a menu for each record that has a unique set of items. This is database driven.

Has anyone tried this with Milonic? If so, can you give me some hints on how to go about it?

Thanks!

DJ


Poster: kevin3442
Dated: Sunday October 29 2006 - 5:30:02 GMT

You can have as many menus on a page as you like, whether they're static or dynamically generated. If you're generating menus from a database, rename your menu_data.js file to menu_data.asp, to force it through the asp processor on the server. In the file, mix static javascript code with the asp code <% ... %> that you use to query your database, get the record set, and loop through it. Instead of outputting html, your asp code will output the javascript code required for the menus.

Hope that helps,

Kevin


Poster: dmcquade
Dated: Monday October 30 2006 - 2:53:30 GMT

Kevin,

That helped a lot! I have one more additional question that may be a little stupid. I have exclueded the database components from this example for testing purposes.

Okay, lets say my main .asp page with the menus has the following lines:

<%
vTest = 1
%>
<p><img src=mmenu.gif border=0 name=mmenu id=mmenu onmouseover="popup('WinePopupFullList','mmenu')" onmouseout=popdown() width="136" height="27"></p>
<%
vTest = 2
%>
<p><img src=mmenu.gif border=0 name=mmenu1 id=mmenu1 onmouseover="popup('WinePopupFullList','mmenu1')" onmouseout=popdown() width="136" height="27"></p>
<%
vTest = 3
%>
<p><img src=mmenu.gif border=0 name=mmenu1 id=mmenu2 onmouseover="popup('WinePopupFullList','mmenu2')" onmouseout=popdown() width="136" height="27"></p>


Now, I want my vTest variable to be visible in the first character of the first two menu items (Again, just for testing). So I change my menu_data.asp file to show as follows:

with(milonic=new menuname("WinePopupFullList")){
style=menuStyle;
aI("text=<% = vTest %>Edit;url=http://www.apache.org/;");
aI("text=<% = vTest %>Delete;url=http://www.apache.org/;");
aI("text=Google;url=http://ww.mysql.com/;");
aI("text=Consume;url=http://www.php.net/;");
aI("text=Consume & Review;url=http://www.phpbb.net/;");
}


The variable value isn't coming across. I can see the variable value if I define it in the menu_data.asp page, but not if I define it in the page calling the menu_data.asp page. Any adivce?

DJ


Poster: kevin3442
Dated: Tuesday October 31 2006 - 2:10:54 GMT

Hi DJ,

The variable is processed on the server side. So it must be used before that code is sent to the client. If you set the variable in the main page (instead of in menu_data.asp), then my thought is that since the two files are being served at different times, its a scope issue.

Two possibilities come to mind:

(1) Bag the menu_data.asp file altogether. Instead, put your menu code right in the main .asp page as inline javascript (i.e., put all of the menu code between javascript <script> </script> tags, rather than loading it from a file). That way, everything is served at once, from the same file.

(2) Instead of trying to set the variable in the main page as an asp variable and then use it in the menu_data file, set the variable in the main page as a global javascript string variable; you can set it from an asp variable, calculation, etc. Then use it in menu_data.asp file as a plain old javascript variable. E.g.,

Main Page:

Code:
<script type="text/javascript">
var vTest = "<%= vT %>";  // set as a string variable
</script>


menu_data.asp:

Code:
with(milonic=new menuname("WinePopupFullList")){
style=menuStyle;
aI("text=" + vTest + "Edit;url=http://www.apache.org/;");
aI("text=Google;url=http://ww.mysql.com/;");
aI("text=Consume;url=http://www.php.net/;");
aI("text=Consume & Review;url=http://www.phpbb.net/;");
}


Hope that helps,

Kevin