Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case functionality

Status
Not open for further replies.

VBStuck

Programmer
Sep 11, 2000
1
US
Hello,

I'm trying to show a user options based on their access level, which is determined by a session variable pulled from a numeric value in a table. Basically, the higher your access level, the more options (links) that would be displayed for you. Each level would add new options, adding on to the previous level of options.

I tried using the Select Case code (below) to identify the options to display, thinking that the Select statement would evauluate each statement and act on all of the true statements, but it only acts on the first statement that evaluates to true.

Any ideas? I was trying to stay away from listing the links multiple times.

Thanks.

Code:
<% Select Case Session(&quot;AccessLevel&quot;)%>
<%Case 1, 2, 3 %>
  <A HREF=&quot;/Edit/srchgcc.asp&quot;>Search</A></H3>
<%Case 2, 3 %>
  <A HREF=&quot;/Edit/newgcc.asp&quot;>Submit New GCC</A></H3>
<%Case 3 %>	
  <A HREF=&quot;/Edit/editlogin.asp&quot;>Add/Edit Login Details</A></H3>
<% End Select %>
[sig][/sig]
 
case evaluates the first match only. This will work...

Code:
<%
Dim acclev
acclev = Session(&quot;AccessLevel&quot;)

if acclev=3 || acclev=2 || acclev=1 then
 response.write &quot;<a href='/edit/srchgcc.asp'>Search</a></h3>&quot;
end if
if acclev=3 || acclev=2 then
 response.write &quot;<a href='/edit/newgcc.asp'>Submit New GCC</a></h3>&quot;
end if
if acclev=3 then
 response.write &quot;<a href='/edit/editlogin.asp'>Add/Edit Login Details</a></h3>&quot;
end if
%>

Note also the response.write. My personal opinion, but I believe the page display is quicker if the asp.dll doesn't have to switch back and forth between asp and non-asp too much. Just an opinion.

Hope this helps,
Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top