troubleshooting Question

Ecart with dynamic quantity drop down menu.

Avatar of imjusthere
imjusthere asked on
Microsoft AccessE-CommerceWeb Applications
2 Comments1 Solution430 ViewsLast Modified:
I'm using ECart and I'm trying to make the quantity into a dynamic drop down menu which only displays the available quantities for that product.  What I currently have displays every quantity in every menu in my looper.

I have two tables in my DB (Access), Proofs and Prices which are related by their Proof ID. I also have two recordsets, Recordset1 (runs Proof table in my looper) and Recordset2 (displays prices).  I don't understand how to set up the Recordset2 so that it only displays the quantities available for that product.  There are multiple quantities and prices for each product.  I hope this makes sense.

Here's my mess:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../WA_eCart/WA_eCart_Definition_VB.asp" -->
<!--#include file="../WA_eCart/eCart1_VB.asp" -->
<!--#include file="../Connections/DSNLESS.asp" -->
<!--#include file="../includes/tNG/tNG.inc.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("kt_Associate") <> "") Then
  Recordset1__MMColParam = Session("kt_Associate")
End If
%>
<%
Dim Recordset1__sort1
Recordset1__sort1 = "%"
If (Request.Form("keywords")  <> "") Then
  Recordset1__sort1 = Request.Form("keywords")
End If
%>
<%
Dim Recordset1__sort2
Recordset1__sort2 = "%"
If (Request.Form("keywords")  <> "") Then
  Recordset1__sort2 = Request.Form("keywords")
End If
%>
<%
Dim Recordset1__sort3
Recordset1__sort3 = "%"
If (Request.Form("keywords")  <> "") Then
  Recordset1__sort3 = Request.Form("keywords")
End If
%>
<%
Dim Recordset1__sort4
Recordset1__sort4 = "%"
If (Request.Form("keywords")  <> "") Then
  Recordset1__sort4 = Request.Form("keywords")
End If
%>
<%
Dim Recordset1__sort5
Recordset1__sort5 = "%"
If (Request.Form("keywords")  <> "") Then
  Recordset1__sort5 = Request.Form("keywords")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_DSNLESS_STRING
Recordset1_cmd.CommandText = "SELECT * FROM proofs WHERE proof_client = ? AND (proof_formNumber LIKE ? OR proof_date LIKE ? OR proof_desc LIKE ? OR proof_keywords LIKE ? OR proof_tab LIKE ?)  ORDER BY proof_date DESC"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 255, Recordset1__MMColParam) ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param2", 200, 1, 255, "%" + Recordset1__sort1 + "%") ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param3", 200, 1, 255, "%" + Recordset1__sort2 + "%") ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param4", 200, 1, 255, "%" + Recordset1__sort3 + "%") ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param5", 200, 1, 255, "%" + Recordset1__sort4 + "%") ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param6", 200, 1, 255, "%" + Recordset1__sort5 + "%") ' adVarChar

Recordset1_cmd.ActiveConnection.CursorLocation = 3
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
Dim RecordsetUsr__MMColParam
RecordsetUsr__MMColParam = "1"
If (Session("kt_login_id") <> "") Then
  RecordsetUsr__MMColParam = Session("kt_login_id")
End If
%>
<%
Dim RecordsetUsr
Dim RecordsetUsr_cmd
Dim RecordsetUsr_numRows

Set RecordsetUsr_cmd = Server.CreateObject ("ADODB.Command")
RecordsetUsr_cmd.ActiveConnection = MM_DSNLESS_STRING
RecordsetUsr_cmd.CommandText = "SELECT Usr_Shopping_Cart, Usr_Invoiced FROM Usr_Usr WHERE ID = ?"
RecordsetUsr_cmd.Prepared = true
RecordsetUsr_cmd.Parameters.Append RecordsetUsr_cmd.CreateParameter("param1", 5, 1, -1, RecordsetUsr__MMColParam) ' adDouble

Set RecordsetUsr = RecordsetUsr_cmd.Execute
RecordsetUsr_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_cmd
Dim Recordset2_numRows

Set Recordset2_cmd = Server.CreateObject ("ADODB.Command")
Recordset2_cmd.ActiveConnection = MM_DSNLESS_STRING
Recordset2_cmd.CommandText = "SELECT * FROM price"
Recordset2_cmd.Prepared = true

Set Recordset2 = Recordset2_cmd.Execute
Recordset2_numRows = 0
%>
<%
Dim Repeat_Recordset1__numRowsHL
Dim Repeat_Recordset1__indexHL

Repeat_Recordset1__numRowsHL = -1
Repeat_Recordset1__indexHL = 0
Recordset1_numRows = Recordset1_numRows + Repeat_Recordset1__numRowsHL
%>
<%
' WA eCart AddToCart
if (cStr(Request.Form("eCart1_1_ATC")) <> "" OR cStr(Request.Form("eCart1_1_ATC.x")) <> "")     then
  ATC_itemID = cStr(Request.Form("eCart1_1_ID_Add"))
  ATC_AddIfIn = 0
  ATC_RedirectAfter = "cart.asp"
  ATC_RedirectIfIn  = ""
  ATC_RSPos = Recordset1.AbsolutePosition
  Recordset1.MoveFirst()
  DO while (NOT Recordset1.EOF)
    if (cStr(Recordset1.Fields("proof_ID").value) = cStr(ATC_itemID))  then
      ATC_itemName = "" & cStr((Recordset1.Fields.Item("proof_client").Value)) & ""' column binding
      ATC_itemDescription = "" & cStr((Recordset1.Fields.Item("proof_desc").Value)) & ""' column binding
      ATC_itemWeight = cDbl("0")' column binding
      ATC_itemQuantity = "" & cStr(Request.Form("eCart1_1_Quantity_Add")) & ""' column binding
      ATC_itemPrice = cDbl("" & cStr((Recordset1.Fields.Item("proof_price").Value)) & "")' column binding
      ATC_itembreak1 = cDbl("" & cStr((Recordset1.Fields.Item("proof_break1").Value)) & "")' column binding
      ATC_itembreak2 = cDbl("" & cStr((Recordset1.Fields.Item("proof_break2").Value)) & "")' column binding
      ATC_itembreak3 = cDbl("" & cStr((Recordset1.Fields.Item("proof_break3").Value)) & "")' column binding
      ATC_itembreak4 = cDbl("" & cStr((Recordset1.Fields.Item("proof_break4").Value)) & "")' column binding
      ATC_itembreak5 = cDbl("" & cStr((Recordset1.Fields.Item("proof_break5").Value)) & "")' column binding
      ATC_itemsavings1 = cDbl("" & cStr((Recordset1.Fields.Item("proof_Savings1").Value)) & "")' column binding
      ATC_itemsavings2 = cDbl("" & cStr((Recordset1.Fields.Item("proof_Savings2").Value)) & "")' column binding
      ATC_itemsavings3 = cDbl("" & cStr((Recordset1.Fields.Item("proof_Savings3").Value)) & "")' column binding
      ATC_itemsavings4 = cDbl("" & cStr((Recordset1.Fields.Item("proof_Savings4").Value)) & "")' column binding
      ATC_itemsavings5 = cDbl("" & cStr((Recordset1.Fields.Item("proof_Savings5").Value)) & "")' column binding
      Exit DO
    end if
    Recordset1.MoveNext()
  Loop
  Recordset1.AbsolutePosition = ATC_RSPos
  if (IsNumeric(ATC_itemQuantity) AND ATC_itemQuantity <> 0)     then
    set eCart1 = eCart1_AddToCart(ATC_AddIfIn, ATC_RedirectIfIn, ATC_itemID, ATC_itemName, ATC_itemDescription, ATC_itemWeight, ATC_itemQuantity, ATC_itemPrice, ATC_itembreak1, ATC_itembreak2, ATC_itembreak3, ATC_itembreak4, ATC_itembreak5, ATC_itemsavings1, ATC_itemsavings2, ATC_itemsavings3, ATC_itemsavings4, ATC_itemsavings5)
    if (ATC_RedirectAfter <> "" AND eCart1_redirStr = "")     then
      eCart1_redirStr = ATC_RedirectAfter
    end if
    Session("WAEC_ContinueRedirect") = cStr(Request.ServerVariables("Script_Name"))  & "?" & cStr(Request.QueryString())
  end if
end if
%>
<%
' WA eCart Redirect
if (eCart1_redirStr <> "")     then
  Response.Redirect(eCart1_redirStr)
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Databar Inc. - Client Library</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script id="PLHFOScript" language="JavaScript" src="../Pluginlab/Scripts/PLHFO.js">/* PLHFOMenu script */</script>

<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
<script src="../includes/cssmenus2/js/cssmenus.js" type="text/javascript"></script>
<script src="../includes/cssmenus2/js/cssmenus.js" type="text/javascript"></script>
<meta name="keywords" content="design databar logo brochures corporate identity forms powerpoint presentations fonts designers designer custom newsletters flash animations animation edgewood washington">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script src="../includes/cssmenus2/js/cssmenus.js" type="text/javascript"></script>
<script src="../includes/cssmenus2/js/animation.js" type="text/javascript"></script>
<link href="../includes/cssmenus2/skins/aqua_blue/horizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}
-->
</style>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body onLoad="PLHFO_onload();MM_preloadImages('../images/emailartdeptdown.jpg','../images/emailassociatedown.jpg')">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top"><table width="100%" border="0" cellspacing="10" cellpadding="10">
      <tr>
        <td valign="top"><h3><span class="style1">Welcome <%= Session("kt_login_user") %> </span> <a href="loginupdate.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image85','','../images/changeaccountdown.jpg',1)"><br>
            <br>
          </a><a href="loginupdate5.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','../images/changeaccountdown.jpg',1)"><img src="../images/changeaccountup.jpg" alt="change login info" name="Image7" width="130" height="26" border="0"></a><a href="loginupdate.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image85','','../images/changeaccountdown.jpg',1)"></a></h3>
          <form name="form1" method="post" action="">
            <label>Keywords
              <input name="keywords" type="text" id="keywords">
  </label>
            <label>
              <input type="submit" name="Submit" value="Search">
              </label>
            <br>
            </form>
          <table width="300" border="1">
            <tr>
              <%
  ' Horizontal Looper version 3
  While ((Repeat_Recordset1__numRowsHL <> 0) AND (NOT Recordset1.EOF))
%>
                <td valign="baseline"><p><a href="<%=tNG_downloadDynamicFile("../", "../proofs/", "{Recordset1.proof_fileName}")%>"><img src="<%=tNG_showDynamicImage("../", "../thumbnails/", "{Recordset1.proof_thumb}")%>" /></a><br>
                  Date: <%=(Recordset1.Fields.Item("proof_date").Value)%><br>
                  Desc.: <%=(Recordset1.Fields.Item("proof_desc").Value)%><br>
                  Form #: <%=(Recordset1.Fields.Item("proof_formNumber").Value)%><br>
                  Keywords: <%=(Recordset1.Fields.Item("proof_keywords").Value)%><br>
                  <a href="emailassociate3.asp?IDNumber=<%=(Recordset1.Fields.Item("proof_ID").Value)%>&assoc=<%=(Recordset1.Fields.Item("proof_associate").Value)%>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image75','','../images/emailassociatedown.jpg',1)"><img src="../images/emailassociateaboutjobup.jpg" alt="email associate about this job" width="190" height="26" border="0" align="absbottom"></a><a href="emailassociate2.asp?IDNumber=<%=(Recordset1.Fields.Item("proof_ID").Value)%>&assoc=<%=(Recordset1.Fields.Item("proof_associate").Value)%>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','../images/emailassociatedown.jpg',1)"></a><br>
                  <a href="emailartdept2.asp?IDNumber=<%=(Recordset1.Fields.Item("proof_ID").Value)%>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','../images/emailartdeptdown.jpg',1)"><img src="../images/emailartdeptup.jpg" alt="email art dept " name="Image8" width="190" height="26" border="0"></a> <a href="reorder.asp?IDNumber=<%=(Recordset1.Fields.Item("proof_ID").Value)%>&assoc=<%=(Recordset1.Fields.Item("proof_associate").Value)%>">
<%
' Show IF Conditional region1
  If (RecordsetUsr.Fields.Item("Usr_Invoiced").Value) = 1 Then
%>
  <img src="../images/ReorderButton.jpg" width="190" height="26" border="0">
  <%
  End If
' End Conditional region1
%>
                  </a><br>
                  <%
' Show IF Conditional region2
  If (Recordset1.Fields.Item("proof_shopping_cart").Value) = 1 Then
%>
                  <form name="eCart1_1_ATC_<%=Recordset1.Fields("proof_ID").value%>" method="POST" action="<%=cStr(Request.ServerVariables("SCRIPT_NAME"))%><%=WA_eCart_IIf((Request.ServerVariables("QUERY_STRING") <> ""), "?" & Request.ServerVariables("QUERY_STRING"), "")%>">
                    <input type="hidden" name="eCart1_1_ID_Add" value="<%=Recordset1.Fields("proof_ID").value%>" >
                    <select name="eCart1_1_Quantity_Add">
                      <option value="1" selected>1</option>
                      <%
While (NOT Recordset2.EOF)
%>
                      <option value="<%=(Recordset2.Fields.Item("price_quantity").Value)%>"><%=(Recordset2.Fields.Item("price_quantity").Value)%></option>
                      <%
  Recordset2.MoveNext()
Wend
If (Recordset2.CursorType > 0) Then
  Recordset2.MoveFirst
Else
  Recordset2.Requery
End If
%>
                    </select>
<input type="submit" value="Add to Cart" name="eCart1_1_ATC">
                  </form>
                  <%
  End If
' End Conditional region2
%></td>
                <%
    'Horizontal Looper version 3
    Repeat_Recordset1__indexHL=Repeat_Recordset1__indexHL+1
    Repeat_Recordset1__numRowsHL=Repeat_Recordset1__numRowsHL-1
    Recordset1.MoveNext()
    if len(nested_Recordset1)<=0 then
      nested_Recordset1 = 1
    end if
    if ((Repeat_Recordset1__numRowsHL <> 0) AND (NOT Recordset1.EOF) AND (nested_Recordset1 mod 4 = 0)) then
      Response.Write "</tr><tr>"
    end if
    nested_Recordset1 = nested_Recordset1 + 1
    'end horizontal looper version 3
  Wend
%>
              </tr>
          </table>          
          <br>        </td>
        </tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
RecordsetUsr.Close()
Set RecordsetUsr = Nothing
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>

Thank you,
Chris
ASKER CERTIFIED SOLUTION
Campbell_David_J

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros