How i can create Seasson variable (ASP) through VBscript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asdasd10
    New Member
    • Apr 2010
    • 14

    #1

    How i can create Seasson variable (ASP) through VBscript

    It is possible create Seasson variable (ASP) through VBscript?
  • GazMathias
    Recognized Expert New Member
    • Oct 2008
    • 228

    #2
    It is done like:
    Code:
    <%
    session("variable") = "value"
    %>
    The Session Object

    Gaz

    Comment

    • asdasd10
      New Member
      • Apr 2010
      • 14

      #3
      i dont mean that i want to get a vbscript variable into Session variable in vb script

      like that

      <script type=text/vbscript>
      dim n
      n = 3
      <%Session("vari able") = %> & n
      </script>

      i want to do somthing like that but its not working

      Comment

      • GazMathias
        Recognized Expert New Member
        • Oct 2008
        • 228

        #4
        i want to do somthing like that but its not working
        Of course it isn't.

        Code between <% and %> is executed at the server and the <script type = text/vbscript> is executed at the browser (IE engine browsers only to my knowledge).

        You therefore have to post the value you want to store in session back to the server using Post or Get and then assign it like I illustrated above.

        Gaz

        Comment

        • asdasd10
          New Member
          • Apr 2010
          • 14

          #5
          look what i wrote :
          Code:
          <%
          Dim n
          n = 1
          %>
          <html>
          <head>
          <script type="text/vbscript" language="VBScript"  >
              Sub buy(obj)
          
          
          <%
          Session("productID") = %>&obj.name
          Msgbox "<%=Session("productID")%>"
          
          
          end sub
                   </script>
          
          </head>
          <body dir="center">
          <%
          path = Server.mappath("../db/ServerData.mdb")
          set con = Server.createobject("ADODB.Connection")
          con.open "driver={Microsoft Access Driver (*.mdb)};DBQ="&path
          set r = con.execute("select * from products")
          response.write "<form method='post'  >"
          response.write "<table border='0' width='100%' cellspacing='50px'>"
          response.write "<tr>"
          response.write "<th>Number</th>"
          response.write "<th>Name</th>"
          response.write "<th>Picture</th>"
          response.write "<th>Description</th>"
          response.write "<th>Price</th>"
          response.write "<th>Quanty</th>"
          response.write "<th>Order</th>"
          response.write "</tr>"
          do until r.eof
          response.write "<tr>"
          response.write "<td>"&r.fields("ItemID")&"</td>"
          response.write "<td>"&r.fields("Name")&"</td>"
          response.write "<td><img src='"&r.fields("Picture")&"'></td>"
          response.write "<td>"&r.fields("Description")&"</td>"
          response.write "<td>"&r.fields("Price")&"</td>"
          response.write "<td><input type='text' size='1' value = '1' ></td>"
          response.write "<td><input type='submit' onclick='buy(me)' value='buy this product' name='"&n&"'></td>"
          response.write "</tr>"
          n=n+1
          r.movenext
          loop
          response.write "</table>"
          response.write "</form>"
          %>
          
          </body>
          </head>
          </html>
          i want to build asp store but simple not somthing hard and at the other page like order.asp i dont know how to find which product the Ueser/client chose
          Last edited by RedSon; Apr 5 '10, 04:30 PM. Reason: CODE TAGS!

          Comment

          • RedSon
            Recognized Expert Expert
            • Jan 2007
            • 4980

            #6
            Next time use code tags. Please read up on "how to ask a question" located here -> http://bytes.com/faq.php?faq=how_to_ask_a_question.

            Please do post code without code tags in the future.

            Comment

            Working...