?
Solved

Classic ASP VBScript: Conditional statement to use various Javascript includes based on user level access

Posted on 2007-10-15
6
Medium Priority
?
1,524 Views
Last Modified: 2010-08-05
Classic ASP VBScript
MS Access
DWMX
WINXP PRO

Hello.  I need assistance with a conditional statement to use a Javascript Include <script> section of code.  My goal is to utilize a section of code pending what level of access the current "Logged-In" user has.  (i.e. "Admin" utilizes one section of code, "User" gets a different one,  "Mentor" gets a different one, etc.)  This section of code is in the <HEAD></HEAD> section.  Here is a brief sketch of a page:

=================================================================================
<@LANGUAGE="VBSCRIPT"%>
<HTML>
<HEAD>

<%If current user level = "Admin" then%>
<script language=javascript src="../Directory/AdminNavBar.js">//</script
<%end if%>

<%If current user level = "User" then%>
<script language=javascript src="../Directory/UserNavBar.js">//</script
<%end if%>

<%If current user level = "Mentor" then%>
<script language=javascript src="../Directory/MentorNavBar.js">//</script
<%end if%>

</HEAD>
<BODY>
STUFF
</BODY>
</HTML>
=================================================================================

I've tried to do an <%If ... then%> statement testing for the user access level of the user logged in for each section of code, but it seems to error out on me.

**(I put the pseudo code in there so you would know what I'm trying to achieve)**
Perhaps someone could let me know how to do this.

Thanks so much!
Shane
0
Comment
Question by:lshane
  • 4
  • 2
6 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20081731
You need a closing bracket on the closing script tag but otherwise what is the problem or error.  The basic idea looks sound to me.  View the browser source to see what the result is.

bol
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 20081760
I would simplify that code to a case statement though.

<HEAD>

<%
Select Case current user level
    Case "Admin"
        Response.Write "<script type=""text/javascript"" src=""../Directory/AdminNavBar.js"">//</script>"
    Case "User"
        Response.Write "<script type=""text/javascript"" src=""../Directory/UserNavBar.js"">//</script>"
    Case "Mentor"
        Response.Write "<script type="text/javascript"" src=""../Directory/MentorNavBar.js"">//</script>"

End select

</HEAD>

I did notice that you used language in the script tag.  That property/attribute is deprecated.  The type property is better and I showed its use above.

Let me know if you have a question or how that works.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20081767
There was a typo.  A missing quote.

    Case "Mentor"
        Response.Write "<script type=""text/javascript"" src=""../Directory/MentorNavBar.js"">//</script>"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lshane
ID: 20082412
Great.  I'll try that b0lsc0tt.
0
 

Author Comment

by:lshane
ID: 20112498
Thanks so much b0lsc0tt!


Shane
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20112796
Your welcome!  I'm glad I could help.  Thanks for another fun question, the grade and the points.

bol
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, 14 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question