Hi everyone, I have a couple of problems related to each other and need help desperately cos I'm pulling my hair out!

I've developed a website for a company who want to take orders but not have a proper shopping cart. I've created a system were you choose the products you want, they then get added to a list of favourites and you can then place a quantity in a box and place your order. The site can be viewed here, you can use "test" and "test" to get in.

The first problem is when I place a quantity in one of the boxes and then click place order, the products are listed out but they repeat the same amount of times as there are products selected as you can see.

My second problem is I would like these quantites to be remembered throughout the session, I've tried to do this with session variables but found it very difficult due to the initial form using a repeat region to display the checkboxes.

So when you are on the product-confirm.asp page the products should list out with their quantities beside them not repeating like they do now and if you want to amend the quantities you can click the amend order button to go back to the product-list.asp page were the quantites will still be the same throughout the session.

Hope this is straightforward, thanks in advance.

Chris

-----------------------------------------------
The code for the product-list.asp page is
-----------------------------------------------

Code:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/alpine.asp" -->
<%
Dim RSprodcat
Dim RSprodcat_numRows

Set RSprodcat = Server.CreateObject("ADODB.Recordset")
RSprodcat.ActiveConnection = MM_alpine_STRING
RSprodcat.Source = "SELECT * FROM prodSubCat"
RSprodcat.CursorType = 0
RSprodcat.CursorLocation = 2
RSprodcat.LockType = 1
RSprodcat.Open()

RSprodcat_numRows = 0
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="index.asp"
MM_grantAccess=false
MM_Username = Session("MM_Username")
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
RSprodlist_numRows = RSprodlist_numRows + Repeat1__numRows
%>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Alpine Foods</title>
<style type="text/css">
<!--
@import url("../alpine.css");
-->
</style>
</head>
<body id="maintain" class="longlist">
<div id="container">
<div id="topshadow"></div>
  <div id="top"><a href="secure.asp"><img src="../images/logo.gif" alt="Alpine Foods" width="238" height="63" border="0" /></a></div>
<div id="navnpic"></div>
    <div id="subnav"></div>
  <div id="mainbody">
    <form method="post" action="product-confirm.asp" name="form1">
    <h2><%= MM_Username %> Shopping List</h2>
    <p>The items below are your favourite items which you have previously ordered, if you wish to order these items again, enter the quantity in the boxes below, if you wish to order different products, click on the add products button. When you are ready to place your order, click on the place order button.</p>
    <p>
      <input type="submit" name="Submit2" value="Place Order" />
      <input name="add2" type="button" class="button" value="Add Products" onclick="window.location.href=('product-categories.asp');" />
    </p>
    <hr />
    <h3>Your Favourites:</h3>
<% 
     Dim iCount
     iCount = 0
     While ((Repeat1__numRows <> 0) AND (NOT RSprodcat.EOF)) 
%>
<%
     Set RSprodlist = Server.CreateObject("ADODB.Recordset")
     RSprodlist.ActiveConnection = MM_alpine_STRING
     RSprodlist.Source = "SELECT * FROM products WHERE productSubCategory = " & RSprodcat.Fields.Item("subCatID").Value & " AND " & MM_Username & " = -1 ORDER BY productTitle ASC"
     RSprodlist.CursorType = 0
     RSprodlist.CursorLocation = 2
     RSprodlist.LockType = 1
     RSprodlist.Open()
     
     Dim iLoop
     
     Do While Not RSprodlist.EOF
     
          strWord = RSprodcat.Fields.Item("subCatTitle").Value
          if strWord = "Soup Products1" then 
          strWord = left(strWord, len(strWord)-1) & " (Ambient)"
          elseif strWord = "Soup Products2" OR strWord = "Fresh & Frozen Raw Meat1" OR strWord = "Cooked Meats1" then
          strWord = left(strWord, len(strWord)-1) & " (Chilled)"
          elseif strWord = "Fresh & Frozen Raw Meat2" OR strWord = "Cooked Meats2" then
          strWord = left(strWord, len(strWord)-1) & " (Frozen)"
          end if

          if str1 <> (RSprodcat.Fields.Item("subCatTitle").Value) Then 
           Response.Write "<h4>" & strWord & "</h4>" & vbCrLf
          end if
          str1 = RSprodcat.Fields.Item("subCatTitle").Value
          
          Response.Write "<dl>"
          Response.Write vbCrLf & "<dt><input type=""text"" class=""quantity"" name=""" & iCount & ".quant"" value=""" & Session(iLoop & ".quant") &""">" & vbCrLf 
          Response.Write "<input type=""hidden"" name=""" & iCount & ".ID"" " & _
                                   "value=""" & RSprodlist("productID") & """>" 
          Response.Write "</dt>" & vbCrLf
          Response.Write "<dd>" & RSprodlist("productTitle") & "</dd>" & vbCrLf
          Response.Write "</dl>" & vbCrLf & vbCrLf

          RSprodlist.MoveNext
          iCount = iCount + 1
          Loop
%>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RSprodcat.MoveNext()
Wend
%>
    <div class="cleaner"></div>
     <hr />
     <p>
       <input type="submit" name="Submit" value="Place Order" />
       <input name="add" type="button" class="button" value="Add Products" onclick="window.location.href=('product-categories.asp');" />
       </p>
     <input type="hidden" name="Count" value="<%=iCount - 1 %>" />
</form>
    <div class="cleaner"></div>
  </div>
  <div id="footer"></div>
</div>
</body>
</html>
<%
RSprodlist.Close()
Set RSprodlist = Nothing
%>
<%
RSprodcat.Close()
Set RSprodcat = Nothing
%>
----------------------------------------------------
The code for the product-confirm.asp page is
----------------------------------------------------

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/alpine.asp" -->
<%
          iCount = Request("Count")
          For iLoop = 0 to iCount
          strQuant = Request(iLoop & ".quant")
          Session(iLoop & ".quant") = strQuant
          Next
%>
<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
  Session.Contents.Remove("MM_Username")
  Session.Contents.Remove("MM_UserAuthorization")
  MM_logoutRedirectPage = "index.asp"
  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_newQS = "?"
    For Each Item In Request.QueryString
      If (Item <> "MM_Logoutnow") Then
        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
      End If
    Next
    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
  End If
  Session.Abandon
  Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="index.asp"
MM_grantAccess=false
MM_Username = Session("MM_Username")
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>
<%
iCount = Request("Count")
%>
<%
Dim RSprodlist
Dim RSprodlist_numRows

Set RSprodlist = Server.CreateObject("ADODB.Recordset")
RSprodlist.ActiveConnection = MM_alpine_STRING
RSprodlist.Source = "SELECT * FROM products WHERE  " & MM_Username & " = -1 ORDER BY productTitle ASC"
RSprodlist.CursorType = 0
RSprodlist.CursorLocation = 2
RSprodlist.LockType = 1
RSprodlist.Open()

RSprodlist_numRows = 0
%>
<%
Dim RSmem__MMColParam
RSmem__MMColParam = "1"
If (Session("MM_Username") <> "") Then 
  RSmem__MMColParam = Session("MM_Username")
End If
%>
<%
Dim RSmem
Dim RSmem_numRows

Set RSmem = Server.CreateObject("ADODB.Recordset")
RSmem.ActiveConnection = MM_alpine_STRING
RSmem.Source = "SELECT * FROM members WHERE memUser = '" + Replace(RSmem__MMColParam, "'", "''") + "'"
RSmem.CursorType = 0
RSmem.CursorLocation = 2
RSmem.LockType = 1
RSmem.Open()

RSmem_numRows = 0

if add1 <> "" then
add1 = Replace(RSmem.Fields.Item("memAddress1"), vbCrLf, "\n")
end if
if add2 <> "" then
add2 = Replace(RSmem.Fields.Item("memAddress2"), vbCrLf, "\n")
end if
if add3 <> "" then
add3 = Replace(RSmem.Fields.Item("memAddress3"), vbCrLf, "\n")
end if
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
RSprodlist_numRows = RSprodlist_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Alpine Foods</title>
<style type="text/css">
<!--
@import url("../alpine.css");
-->
</style>
</head>
<body id="maintain">
<div id="container">
<div id="topshadow"></div>
  <div id="top"><a href="secure.asp"><img src="../images/logo.gif" alt="Alpine Foods" width="238" height="63" border="0" /></a><a href="<%= MM_Logout %>">logout</a></div>
  <div id="navnpic"></div>
    <div id="subnav"></div>
  <div id="mainbody">
    <h2><%= MM_Username %> Shopping List Confirmation </h2>
          <form id="form1" name="form1" method="post" action="product-confirm.asp">
     <div id="shoplist">
                <ul id="list">
            <% 
While ((Repeat1__numRows <> 0) AND (NOT RSprodlist.EOF)) 
%>
<%
       For iLoop = 0 to iCount
       strQuant = Request(iLoop & ".quant")
%>
            <li><strong><%=strQuant%> x</strong> <%=(RSprodlist.Fields.Item("productTitle").Value)%></li>
<%
       Next
%>
<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RSprodlist.MoveNext()
Wend
%>
                </ul>
    <div class="cleaner"></div>
     <p>
      <input name="add" type="button" class="button" value="Amend Order" onclick="window.location.href=('product-list.asp');" />
      <input type="submit" name="Submit" value="Place Order" />
    </p>
            </div>
            <div id="otherform">
              <p>
                <label for="textfield">Delivery Address</label>
                <textarea name="address" cols="26" rows="7" id="address"><%=(RSmem.Fields.Item("memAddress1").Value)%></textarea>
              <br />
               <% if RSmem.Fields.Item("memAddress2").Value <> "" then %>
               <a href="#" onclick="document.form1.address.value='<%=add1%>'; return false;">Address 1</a> | <a href="#" onclick="document.form1.address.value='<%=add2%>'; return false;">Address 2</a> 
               <% end if %>               
               <% if RSmem.Fields.Item("memAddress3").Value <> "" then %>
               | <a href="#" onclick="document.form1.address.value='<%=add3%>'; return false;">Address 3</a> 
               <% end if %>
              </p>
              <p>
                <label for="textfield">Special Delivery Instructions </label>
                <textarea name="specdel" cols="26" rows="7" id="specdel">
</textarea>
              </p>
              <p>
                <input name="add2" type="button" class="button" value="Amend Order" onclick="window.location.href=('product-list.asp');" />
              <input type="submit" name="Submit2" value="Place Order" />
</p>
            </div>
          </form>
    <div class="cleaner"></div>
  </div>
  <div id="footer"></div>
</div>
</body>
</html>
<%
RSprodlist.Close()
Set RSprodlist = Nothing
%>
<%
RSmem.Close()
Set RSmem = Nothing
%>