-
Help whit a menu
Hi all!
Ok... I have bought a men u called CoolMenu and it is writen i javacript. Here s my problem!
I am using a dropdown menu that i want to replace with the new one i just boughted. in the old one i have an asp routine that builds the menu from a database. Then new one has a routine that also build the menu from a db. My problem is that i want to use my DB and my routine to buld the new menu. ANd i dont know Javascript. So i need some help to get the new menu to run on my routine...And i still want the new mnu to run on javascript
Down below is my asp code..and a description on the old menu
Code:
<script language="JavaScript" src="/Meny/advancedmenu.js"></script>
<script>
/*
initmenu parameters in sequence order are:
1. No of top levels.
2. Height of individual item.
3. Width of individual item.
4. Delay interval in milliseconds.
5. Layout type- The value of this parameter should be either horizontal or vertical.
*/
initmenu(5,20,79,200,"horizontal");
/*addmenuitem parameters in sequence order are:
1. Node.
2. Description which shows up.
3. URL associated with the Description.
4. Onmouseover text color.
5. Onmouseover background color.
6. Onmouseout/default text color.
7. Onmouseout/default Background color.
8. Onmousedown/default text color.
9. Onmousedown/default Background color.
10.String containing font values.
*/
</script>
<!-- #include virtual="Customer/connect.asp" -->
<% four = "#000"
five = "#ccc"
six = "#fff"
seven = "#000"
eight = "#000"
nine = "#ccc"
strFontVal = "font-family: Verdana, Arial; font-size: 10px; font-weight: 700; vertical-align: top; padding-top: 2px; padding-bottom: 3px; padding-left: 3px;"
%>
<%
'==============================================================================
' Gets all headmenu from the database
'==============================================================================
Visa = "SELECT * FROM tbl_HEADMENU where active=1"
Set REcSet=connect.execute(Visa)
'RecSet.Open Visa, Connect, adOpenStatic, adLockOptimistic
Set RecSet2 = Server.CreateObject("ADODB.Recordset")
'==============================================================================
' Do a loop thrue the menus
'==============================================================================
Do While Not RecSet.EOF
' Sparar undan posterna i variblar som anvädnds för att bygga menyn
strPlacering = RecSet("placement")
strText = trim(RecSet("MenuName"))
strLink = RecSet("menuLink")
'strSubmeny = RecSet("Submeny")
'==============================================================================
' The Javacript thats builds the menu
'==============================================================================
%>
<script>
addmenuitem("<%=strPlacering %>","<%=strText %>","<%=strLink %>","<%=four%>","<%=five%>","<%=six%>","<%=seven%>","<%=eight%>","<%=nine%>","<%=strFontVal%>");
</script>
<%
'==============================================================================
' Gets the information on the submenu from the database
'==============================================================================
SQLsub="select a.*, bb.placement, bb.active from tbl_SUBMENU a, tbl_HEADMENU bb" & _
" WHERE bb.placement = a.headMenuID " & _
" AND bb.active = a.active " & _
" AND bb.active=1 AND a.headMenuID='" & strPlacering & "'"
set recSet2 = connect.execute(SQLsub)
'RecSet2.Open SQLsub, Connect, adOpenStatic, adLockOptimistic
'==============================================================================
' Do a loop true the Submenu and builds it under each headmenu
'==============================================================================
do while not RecSet2.EOF
' Sparar undan posterna i variblar som anvädnds för att bygga undermenynmenyn
strPlacering = RecSet("placement")
strID = RecSet2("subPlacement")
strSubText = trim(RecSet2("subMenuName"))
strSubLink = RecSet2("SubLink")
strParentMenu = RecSet2("headMenuID")
'==============================================================================
' The Javascript thats builds the submenus
'==============================================================================
%>
<script>
addmenuitem("<%= strPlacering %>,<%= strID %>","<%= strSubText %>","<%= strSubLink %>","<%=four%>","<%=five%>","<%=six%>","<%=seven%>","<%=eight%>","<%=nine%>","<%=strFontVal%>");
</script>
<%
'==============================================================================
' Ends the loop for submenu
'==============================================================================
RecSet2.MoveNext
Loop
RecSet2.Close
'==============================================================================
' Ends the loop for the headmenu
'==============================================================================
RecSet.MoveNext
Loop
RecSet.Close
%>
<script>
createmenu();
add10xitems();
</script>
Here is the new menu DB routine
Code:
<%@language="JScript"%>
<%
var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("data.mdb") + ";Persist Security Info=False";
%>
// styles
var color = {"border":"#666666", "shadow":"#DBD8D1", "bgON":"white","bgOVER":"#B6BDD2"};
var css = {"ON":"clsCMOn", "OVER":"clsCMOver"};
var STYLE = {"border":1, "shadow":2, "color":color, "css":css};
// items and formats
var MENU_ITEMS = [
{"pos":"relative", "itemoff":[0,119], "leveloff":[21,0], "style":STYLE, "size":[22,120]},
<%
Response.Expires = 0;
function getChildren(connection, parent) {
var results = connection.Execute("select * from structure where not disabled and id <> 0 and parent = " + parent);
var list = new Array();
while (!results.EOF) {
list[list.length] = new Array(
results("caption").value,
results("url").value,
results("target").value
);
var children = getChildren(connection, results("id"));
if (children.length > 0)
list[list.length - 1][3] = children;
results.MoveNext();
}
results.Close();
return list;
}
function getItems(connection) {
return getChildren(connection, 0);
}
function printItems(items, depth) {
if (!depth) depth = 0;
var s = '', last = items.length - 1, i;
for (i = 0; i <= last; i++) {
var item = items[i];
if (i > 0)
s += ',';
if (i > 0)
s += "\n";
s += '{"code":"' + item[0] + '"';
if (item[1] != '' && item[1] != 'null' && item[1] != null)
s += ', "url":"' + item[1] + '"';
if (item[2] != '' && item[2] != 'null' && item[2] != null)
s += ', "target":"' + item[2] + '"';
if (item[3]) {
if (depth == 0)
s += ", \"sub\":[\n{\"itemoff\":[21,0], \"leveloff\":[0,0]},\n";
else
s += ", \"sub\":[\n{\"itemoff\":[21,0], \"leveloff\":[11,109]},\n";
s += printItems(item[3], depth + 1);
s += ']';
}
s += "}";
}
if (depth > 0)
s += "\n";
return s;
}
var connection = Server.CreateObject("ADODB.Connection");
connection.Open(connectionString);
Response.Write(printItems(getItems(connection)));
connection.Close();
%>
];
On http://javascript.cooldev.com/script...menupro/demos/
is a very good description on the menu...
Summary: i need help to take my SQL questions and make them run on the new coolmenu i boughted
Thanks all!
Tyson