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: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:35

Help for those using ASP to code menus!


Poster: Grail Soulchaser
Dated: Friday June 14 2002 - 6:21:46 BST

I've been reading through some topics from people asking for help with coding the menus for dynamic links through ASP. I use this on a couple of my sites, so I thought I'd share the secret.

The problem comes from Javascript confusing the ' character, and the " character. ASP uses the " character to enclose strings.. so in order to tell javascript the proper syntax, you need to use the character code.. which under ASP is ... chr(34) .

I've copied a section from my code to show how this works
It's rather large, so you may want to copy paste it so you can view it properly... hope this helps you all out...

This particular piece of code changes the menu based on whether a user is logged into the database, and what security level he has.. it's a simple site, so there are only 2 security levels.. makes it quite simple.

<%
If Session("CJLI") = True Then
Aopts = "addmenu(menu=[" & chr(34) & "admin" & chr(34) & "," &_
",,120,1," & chr(34) & chr(34) & ",style2,,,effect,,,,,,,,,,,,"
If Session("Sec") = 9 Then
Aopts = Aopts &_
"," & chr(34) & "Set Battle" & chr(34) & "," & chr(34) & "a-battles.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Set Monthly Battle" & chr(34) & ",1" &_
"," & chr(34) & "Wipe Database" & chr(34) & "," & chr(34) & "wipedb.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Wipe the Database" & chr(34) & ",1" &_
"," & chr(34) & "Post SP Results" & chr(34) & "," & chr(34) & "postsp.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Post Single Player Results" & chr(34) & ",1" &_
"," & chr(34) & "Edit MP Scores" & chr(34) & "," & chr(34) & "editmp.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Edit Multiplayer Scores" & chr(34) & ",1"
Else
Aopts = Aopts &_
"," & chr(34) & "Player Edit" & chr(34) & "," & chr(34) & "pedit.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Edit your Player Info" & chr(34) & ",1" &_
"," & chr(34) & "Submit SP" & chr(34) & "," & chr(34) & "tiger01 __at__ cableone.net swapimage=gfx/bShow.jpg;" & chr(34) & ",,,1" &_
"," & chr(34) & "Report MP" & chr(34) & "," & chr(34) & "submit.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Report Multiplayer Scores" & chr(34) & ",1"
End If
Aopts = Aopts & _
"," & chr(34) & "Logout" & chr(34) & "," & chr(34) & "cjlogout.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Logout of Administration" & chr(34) & ",1" &_
"])"
Else
Aopts = "addmenu(menu=[" & chr(34) & "admin" & chr(34) & "," &_
",,120,1," & chr(34) & chr(34) & ",style2,,,effect,,,,,,,,,,,," & _
"," & chr(34) & "Login" & chr(34) & "," & chr(34) & "cjlogin.asp swapimage=gfx/bShow.jpg;" & chr(34) & ",," & chr(34) & "Login" & chr(34) & ",1" &_
"])"
End If
%>

After coding this piece.. all you need to do is in the Javascript section responsible for creating your menu, place the line:

<% Response.Write(Aopts) %>

and suddenly, it all works! :)

If anyone needs extra help.. feel free to ask me...