4 Replies Latest reply on Sep 5, 2007 5:06 AM by Newsgroup_User

    Accessing Variables in ASP

    rossmgreenberg Level 1
      I am trying to access based upon a numeric database field called "label". How do I display a different menu based upon that access level: for example, I want to display a menu on a page if the value of that field is less than 3, a different menu -- with access to different items -- if the menu value is greater than 3.

      How do I do that?

      Thanks!

      Ross
        • 1. Re: Accessing Variables in ASP
          bregent Most Valuable Participant
          Several ways to do this. I'd probably do something like this:

          <%
          if label < 3 then
          %>
          <!--#include file="menu1.inc" -->
          <%
          Else
          %>
          <!--#include file="menu2.inc" -->
          <%
          End if
          %>
          • 2. Re: Accessing Variables in ASP
            Level 7
            On Tue, 4 Sep 2007 21:58:59 +0000 (UTC), "bregent"
            <webforumsuser@macromedia.com> wrote:

            > <%
            > if label < 3 then
            > %>
            > <!--#include file="menu1.inc" -->

            Are you certain that will work? I don't mess with ASP much any more, but
            I seem to remember that ASP processes any include directives before
            executing the VBScript.
            • 3. Re: Accessing Variables in ASP
              bregent Most Valuable Participant
              ?Are you certain that will work? I don't mess with ASP much any more, but
              ?I seem to remember that ASP processes any include directives before
              ?executing the VBScript.

              Gary, you are correct in that include directives are processed first, which is why you can't do true conditional includes. But the code still works. Both menus 1 and 2 will be included in the code send to the ASP processor. The VBScript will then either display the html for menu 1 or 2 depending on the value of 'label'.

              In other words, the script doesn't determine which menu gets inserted into the code sent to the ASP scripting engine, but it does determine the html sent to the browser. Hope this makes sense.
              • 4. Re: Accessing Variables in ASP
                Level 7
                On Wed, 5 Sep 2007 04:18:00 +0000 (UTC), "bregent"
                <webforumsuser@macromedia.com> wrote:

                > In other words, the script doesn't determine which menu gets inserted into the
                >code sent to the ASP scripting engine, but it does determine the html sent to
                >the browser. Hope this makes sense.


                Aha! That makes perfect sense. Thanks for straightening me out.