Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Javascript Menu

  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Menu

    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.

  • #2
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Okay, for starters.... There are ways that ASP can interact with Client Side Javascript.....



    Code:
    <%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%>

    hope that that helps!

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Quote Originally Posted by jaywhy13
    Okay, for starters.... There are ways that ASP can interact with Client Side Javascript.....



    Code:
    <%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%>

    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

    Code:
    <%
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •