"Shopping Without a Cart: Using IE 4.0 for a More Efficient E-Commerce User Interface"
by Lauren Hightower
Web Techniques, November 1998

Web Techniques grants permission to use these listings (and code) for 
private or commercial use provided that credit to Web Techniques and 
the author is maintained within the comments of the source. For 
questions, contact editors@web-techniques.com. 



[LISTING ONE]


<%@ LANGUAGE="VBSCRIPT" %>

<%
    Set dbConn = Server.CreateObject("ADODB.Connection")
    dbConn.Open "MSStore"
    SQL = "SELECT Category.CategoryID, Category.CategoryName FROM 
           Category WHERE CategoryId in (SELECT categoryID FROM product) 
           ORDER BY CategoryName;"
    Set rsCategories = dbConn.Execute(SQL)
%>

....

    <% 
        Do until rsCategories.EOF
    %>
    
    <option value=<%=rsCategories.Fields("CategoryId")%>><%=rsCategories.Fields("CategoryName")%>

    <%
        rsCategories.MoveNext
        Loop
    %>



[LISTING TWO]


Dim rds, objBusObj, opRecordset, currPrice, currTotal

' -------------------------------------
' Create the dataspace object
' -------------------------------------
Set rds = CreateObject("RDS.DataSpace")

' -----------------------------------------
' Instantiate the business object on server
' -----------------------------------------
Set objBusObj = rds.CreateObject("WT.NWData", "http://<%=Request.ServerVariables("SERVER_NAME")%>")

' -----------------------------------------
' Call the procedure in the business object
' -----------------------------------------
objBusObj.GetProducts opRecordset



[LISTING THREE]


SUB lstCategories_OnChange
    
    Dim rsProds, opt, i, sProds

    tdProduct.innerhtml = "&nbsp"

    ' -------------------------------------
    ' Set the temporary recordset to the entire list of products
    ' -------------------------------------
    set rsProds = rsAllProducts
    
    ' -------------------------------------
    ' Create the recordset with the appropriate products
    ' -------------------------------------
    rsProds.Filter = "categoryId = " & lstCategories.value
   
    ' -------------------------------------
    ' Delete the current entries in the products list box
    ' -------------------------------------
    For i = 0 to (lstProducts.options.length-1)
        lstProducts.options.remove 0
    Next

    ' -------------------------------------
    ' Fill the list with the right products
    ' -------------------------------------
    Do until rsProds.eof
        set opt = document.createelement("option")
        opt.text= rsProds.Fields("ProductName")
        opt.Value = rsProds.Fields("ProductId")
        lstProducts.options.add opt
        set opt=nothing
        rsProds.MoveNext
    Loop

    ' -------------------------------------
    ' Clean Up
    ' -------------------------------------
    Set rsProds = Nothing
END SUB



[LISTING FOUR]


Option Explicit


Public Sub GetProducts(rsAllProducts As Variant)
    ' -------------------------------------
    ' Create the recordset
    ' -------------------------------------
    Dim cnHome, sSQL
    
    Set cnHome = CreateObject("ADODB.Connection")
    cnHome.Open "MSStore"
    sSQL = "SELECT CategoryID, ProductPrice, ProductId, ProductName, ProductDescription, 
            ProductPrice FROM Product"
   
    Set rsAllProducts = CreateObject("ADODB.Recordset")

    ' -------------------------------------
    ' Set CursorLocation so recordset will become
    ' an ADOR recordset
    ' -------------------------------------
    rsAllProducts.CursorLocation = adUseClientBatch
    rsAllProducts.Open sSQL, cnHome, adOpenForwardOnly, adLockReadOnly

End Sub



[LISTING FIVE]


SUB lstProducts_OnClick
    Dim sProductInfo, rsProductInfo, sTemp

    Set rsProductInfo = rsAllProducts
    rsProductInfo.filter = "productId=" & lstProducts.Value

    sProductInfo = "<table border=0 cellpadding=2>"

    sProductInfo = sProductInfo & "<tr><td valign=top><img src=images/product" 
                                & trim(lstProducts.value) & ".gif></td>"

    sProductInfo = sProductInfo & "<td valign=top>" 
                                & rsProductInfo.Fields("ProductDescription") & "</td></tr>"

    sProductInfo = sProductInfo & "<tr><td valign=top colspan=2><font size=-1><b>PRICE:</b> $" 
                                & rsProductInfo.Fields("ProductPrice") 
                                & "<br><a href=""VBScript:OrderProduct"">
                                   <img src=""images/buyit.gif"" border=0></a></td></tr>"

    sProductInfo = sProductInfo & "</table>"

    currPrice = rsProductInfo.Fields("ProductPrice")

    tdProduct.innerhtml = sProductInfo

    Set rsProductInfo = Nothing

END SUB



[LISTING SIX]


FUNCTION OrderProduct
Dim iTax
    currTotal = currTotal + currPrice
    iTax = currTotal * .07
    iTax = FormatNumber(iTax, 2)
    currTotal = currTotal + iTax
    currTotal = FormatNumber(currTotal, 2)

    tdOrders.innerhtml = tdOrders.innerhtml 
                         & lstProducts.options(lstProducts.selectedindex).text & "<br>"
    tdPrices.innerhtml = tdPrices.innerhtml & FormatNumber(currPrice,2) & "<br>"
    tdTotal.innerhtml = "$ " & currTotal
    tdTax.innerHTML = "$ " & iTax
    
END FUNCTION