...

View Full Version : Javascript Menu



sonal
01-18-2005, 11:23 AM
I want to create javascript menu dynamically using asp in which the menu will come according to the module rights given.

ex.
if admin has signed in then all the modules will be displayed
if user has signed in then only those modules which has rights will be displayed.

jaywhy13
01-18-2005, 02:56 PM
Okay, for starters.... There are ways that ASP can interact with Client Side Javascript.....
:thumbsup:




<%some ASP code
'User authentication.... using an index to represent privelege
userLevel=0
%>

<script language="Javascript">
privelegeLevel=<%=userLevel%>

if(privelegeLevel==0)
{
//Do some stuff
}
else if(privelegeLevel>0)
{
//Possibly administrator? Show all menus and stuff?
}

</script>

If you look in the 1st line of the Javascript there I have used ASP variable to write in the data for a Client Side Variable....

I hope that principle helps you out! And beware using this method.... That is, writing ASP in Javascript.... it only allows a line long of code in Javascript
So:
Don't try this:
<%
Some asp code
more asp code
%>

Rather do:
<%some asp code%>
<%more asp code%>

:D hope that that helps!

brothercake
01-18-2005, 04:20 PM
My menu comes with an ASP builder, if that's helpful - http://www.udm4.com/ Might give you some ideas if it's not directly useful

ghell
01-19-2005, 11:19 AM
Okay, for starters.... There are ways that ASP can interact with Client Side Javascript.....
:thumbsup:




<%some ASP code
'User authentication.... using an index to represent privelege
userLevel=0
%>

<script language="Javascript">
privelegeLevel=<%=userLevel%>

if(privelegeLevel==0)
{
//Do some stuff
}
else if(privelegeLevel>0)
{
//Possibly administrator? Show all menus and stuff?
}

</script>

If you look in the 1st line of the Javascript there I have used ASP variable to write in the data for a Client Side Variable....

I hope that principle helps you out! And beware using this method.... That is, writing ASP in Javascript.... it only allows a line long of code in Javascript
So:
Don't try this:
<%
Some asp code
more asp code
%>

Rather do:
<%some asp code%>
<%more asp code%>

:D hope that that helps!

strange, i can do multiple lines without any problems, as long as what you output is separated by vbNewLines if it is on a differnent line (semicolons separate lines anyway but a lot of people dont use them)

ideally you should not use a javascript variable for the access level as this can be changed on the client side so unless you have a lot of security on each page (which you should anyway) it will be easy to simulate an administrative logon. you could do this



<%
privelegeLevel = 0

'set the privelege level of the user here
...
%>
<script type="text/javascript">
<!--
<%
If privelegeLevel = 0 Then
'insert member javascript with each line of code separated by vbNewLines and ;s
Else
'insert admin javascript with each line of code separated by vbNewLines and ;s
End If
%>
//-->
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum