Solved

how to have a hidden field value cahange based on anothe drop down choice?

Posted on 2007-11-15
17
235 Views
Last Modified: 2010-04-07
Hi

I have been putting together an online store and all seems to be functioning ok. The only problem that  can't figure out is this:

Some items have different sizes with different prices (some don't) I have dealt with showing or not showing 'Size' drop down if there is no size. But when I have a drop down and the sizes are for example Small Medium Large and relative prices are £5 £7.50 £10. I can't see a way to carry the relevant price to the checkout page (which at the moment only receives the FORST price in the recordst on the previous page.

I've tried various ways of posting the form back to it's own page to set the recordset value but can't get this to work. Any ideas would be welcome

Thanks.

the Add to bag form part of the page is (full code below):

 <p>Choose your required colour and size and select a quantity:</p>
        <form name="magecart_1_ATC_<%=RsDetail.Fields("ProdID").value%>" method="POST" action="<%=cStr(Request.ServerVariables("SCRIPT_NAME"))%><%=WA_eCart_IIf((Request.ServerVariables("QUERY_STRING") <> ""), "?" & Request.ServerVariables("QUERY_STRING"), "")%>">
          <input type="hidden" name="magecart_1_ID_Add" value="0" />
          <input type="hidden" name="magecart_1_Name_Add" value="<%=(RsDetail.Fields.Item("ProdName").Value)%>" />
          <input type="hidden" name="magecart_1_Description_Add" value="<%=(RsDetail.Fields.Item("ProdShortDesc").Value)%>" />
          <input type="text" name="magecart_1_Quantity_Add" value="1" size="4" />
          <% If (RsColour.Fields.Item("CountOfProdAvailColour").Value)>= 2 Then %>
                 <select name="magecart_1_Colour_Add" id="magecart_1_Colour_Add">
                   <%
While (NOT RsColourName.EOF)
%><option value="<%=(RsColourName.Fields.Item("AvailColourName").Value)%>"><%=(RsColourName.Fields.Item("AvailColourName").Value)%></option><%
  RsColourName.MoveNext()
Wend
If (RsColourName.CursorType > 0) Then
  RsColourName.MoveFirst
Else
  RsColourName.Requery
End If
%>
</select>
      <% Else %>
      <input name="magecart_1_Colour_Add" type="hidden" value="<%=(RsDetail.Fields.Item("AvailColourName").Value)%>" />
      <% End If %>
      <% If Not(RsDetail.Fields.Item("SizeName").Value) = "None" Then %>
                      <select name="magecart_1_Size_Add" id="magecart_1_Size_Add">
             <%
While (NOT RsDetail.EOF)
%>
             <option value="<%=(RsDetail.Fields.Item("SizeName").Value)%>"><%=(RsDetail.Fields.Item("SizeName").Value)%></option>
             <%
  RsDetail.MoveNext()
Wend
If (RsDetail.CursorType > 0) Then
  RsDetail.MoveFirst
Else
  RsDetail.Requery
End If
%>
</select>
                    <input type="hidden" name="magecart_1_Price_Add" value="<%=(RsDetail.Fields.Item("Price").Value)%>" />
                    <% Else %>
      <input name="magecart_1_Size_Add" type="hidden" value="<%=(RsDetail.Fields.Item("SizeName").Value)%>" />
      <% End If %>
          <input type="image" src="WA_eCart/Images/Pacifica/Btn2_EN_addtocart.gif" border="0" value="Add to Cart" name="magecart_1_ATC">
        </form>

****************************************************************************************************************************

The entire page is:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="WA_eCart/WA_eCart_Definition_VB.asp" -->
<!--#include file="WA_eCart/magecart_VB.asp" -->
<!--#include file="Connections/MagicalRooms.asp" -->
<%
Dim RsImageFeatured__MMColParam
RsImageFeatured__MMColParam = "393"
If (Request.QueryString("ProdID") <> "") Then
  RsImageFeatured__MMColParam = Request.QueryString("ProdID")
End If
%>
<%
Dim RsImageFeatured
Dim RsImageFeatured_cmd
Dim RsImageFeatured_numRows

Set RsImageFeatured_cmd = Server.CreateObject ("ADODB.Command")
RsImageFeatured_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsImageFeatured_cmd.CommandText = "SELECT tblProducts.ProdName, tblImages.Image FROM tblProducts LEFT JOIN tblImages ON tblProducts.ProdID = tblImages.ProdID WHERE (((tblImages.Featured)=True) AND ((tblProducts.ProdID)= ? )) GROUP BY tblProducts.ProdName, tblImages.Image"
RsImageFeatured_cmd.Prepared = true
RsImageFeatured_cmd.Parameters.Append RsImageFeatured_cmd.CreateParameter("param1", 5, 1, -1, RsImageFeatured__MMColParam) ' adDouble

Set RsImageFeatured = RsImageFeatured_cmd.Execute
RsImageFeatured_numRows = 0
%>
<%
Dim RsImages__MMColParam
RsImages__MMColParam = "393"
If (Request.QueryString("ProdID")  <> "") Then
  RsImages__MMColParam = Request.QueryString("ProdID")
End If
%>
<%
Dim RsImages
Dim RsImages_cmd
Dim RsImages_numRows

Set RsImages_cmd = Server.CreateObject ("ADODB.Command")
RsImages_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsImages_cmd.CommandText = "SELECT tblProducts.ProdName, tblImages.Image FROM tblProducts LEFT JOIN tblImages ON tblProducts.ProdID = tblImages.ProdID WHERE (((tblImages.Featured)=False) AND ((tblProducts.ProdID)= ? )) GROUP BY tblProducts.ProdName, tblImages.Image"
RsImages_cmd.Prepared = true
RsImages_cmd.Parameters.Append RsImages_cmd.CreateParameter("param1", 5, 1, -1, RsImages__MMColParam) ' adDouble

Set RsImages = RsImages_cmd.Execute
RsImages_numRows = 0
%>
<%
Dim RsDetail__MMColParam
RsDetail__MMColParam = "393"
If (Request.QueryString("ProdID")       <> "") Then
  RsDetail__MMColParam = Request.QueryString("ProdID")      
End If
%>
<%
Dim RsDetail
Dim RsDetail_cmd
Dim RsDetail_numRows

Set RsDetail_cmd = Server.CreateObject ("ADODB.Command")
RsDetail_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsDetail_cmd.CommandText = "SELECT tblProducts.ProdName, tblProducts.ProdLongDesc, tblAvailColours.AvailColourName, tblSizeGroup.SizeName, tblPrice.Price, tblPrice.PriceDiscMin, tblPrice.PriceDiscPrice, tblStock.Quantity, tblSizeGroup.SizeGroupID, tblAvailColours.AvailColourID, tblPrice.PriceID, tblProducts.ProdID, tblProducts.ProdShortDesc FROM ((tblProducts LEFT JOIN (tblSizeGroup RIGHT JOIN (tblStock LEFT JOIN tblPrice ON tblStock.StockProdID = tblPrice.PriceProdID) ON tblSizeGroup.SizeGroupID = tblPrice.PriceSizeID) ON tblProducts.ProdID = tblStock.StockProdID) LEFT JOIN tblImages ON tblProducts.ProdID = tblImages.ProdID) LEFT JOIN (tblAvailColours RIGHT JOIN tblProdColours ON tblAvailColours.AvailColourID = tblProdColours.ProdAvailColour) ON tblProducts.ProdID = tblProdColours.ProdProdID WHERE (((tblProducts.ProdID)= ? )) GROUP BY tblProducts.ProdName, tblProducts.ProdLongDesc, tblAvailColours.AvailColourName, tblSizeGroup.SizeName, tblPrice.Price, tblPrice.PriceDiscMin, tblPrice.PriceDiscPrice, tblStock.Quantity, tblSizeGroup.SizeGroupID, tblAvailColours.AvailColourID, tblPrice.PriceID, tblProducts.ProdID, tblProducts.ProdShortDesc"
RsDetail_cmd.Prepared = true
RsDetail_cmd.Parameters.Append RsDetail_cmd.CreateParameter("param1", 5, 1, -1, RsDetail__MMColParam) ' adDouble

Set RsDetail = RsDetail_cmd.Execute
RsDetail_numRows = 0
%>
<%
Dim RsColour__MMColParam
RsColour__MMColParam = "392"
If (Request.QueryString("ProdID")      <> "") Then
  RsColour__MMColParam = Request.QueryString("ProdID")    
End If
%>
<%
Dim RsColour
Dim RsColour_cmd
Dim RsColour_numRows

Set RsColour_cmd = Server.CreateObject ("ADODB.Command")
RsColour_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsColour_cmd.CommandText = "SELECT Count(tblProdColours.ProdAvailColour) AS CountOfProdAvailColour FROM tblProducts INNER JOIN (tblAvailColours INNER JOIN tblProdColours ON tblAvailColours.AvailColourID = tblProdColours.ProdAvailColour) ON tblProducts.ProdID = tblProdColours.ProdProdID WHERE (((tblProdColours.ProdProdID)= ?))"
RsColour_cmd.Prepared = true
RsColour_cmd.Parameters.Append RsColour_cmd.CreateParameter("param1", 5, 1, -1, RsColour__MMColParam) ' adDouble

Set RsColour = RsColour_cmd.Execute
RsColour_numRows = 0
%>
<%
Dim RsColourName__MMColParam
RsColourName__MMColParam = "392"
If (Request.QueryString("ProdID") <> "") Then
  RsColourName__MMColParam = Request.QueryString("ProdID")
End If
%>
<%
Dim RsColourName
Dim RsColourName_cmd
Dim RsColourName_numRows

Set RsColourName_cmd = Server.CreateObject ("ADODB.Command")
RsColourName_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsColourName_cmd.CommandText = "SELECT tblAvailColours.AvailColourName FROM tblProducts INNER JOIN (tblAvailColours INNER JOIN tblProdColours ON tblAvailColours.AvailColourID = tblProdColours.ProdAvailColour) ON tblProducts.ProdID = tblProdColours.ProdProdID WHERE (((tblProdColours.ProdProdID)= ? ))"
RsColourName_cmd.Prepared = true
RsColourName_cmd.Parameters.Append RsColourName_cmd.CreateParameter("param1", 5, 1, -1, RsColourName__MMColParam) ' adDouble

Set RsColourName = RsColourName_cmd.Execute
RsColourName_numRows = 0
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = -2
Dim HLooper1__index
HLooper1__index = 0
RsImages_numRows = RsImages_numRows + HLooper1__numRows
%>
<%
' WA eCart AddToCart
if (cStr(Request.Form("magecart_1_ATC")) <> "" OR cStr(Request.Form("magecart_1_ATC.x")) <> "")     then
  ATC_itemID = cStr(Request.Form("magecart_1_ID_Add"))
  ATC_AddIfIn = 0
  ATC_RedirectAfter = "bag.asp"
  ATC_RedirectIfIn  = ""
    ATC_itemName = "" & cStr(Request.Form("magecart_1_Name_Add")) & ""' column binding
    ATC_itemDescription = "" & cStr(Request.Form("magecart_1_Description_Add")) & ""' column binding
    ATC_itemWeight = cDbl("0")' column binding
    ATC_itemQuantity = "" & cStr(Request.Form("magecart_1_Quantity_Add")) & ""' column binding
    ATC_itemPrice = "" & cStr(Request.Form("magecart_1_Price_Add")) & ""' column binding
    ATC_itemColour = "" & cStr(Request.Form("magecart_1_Colour_Add")) & ""' column binding
    ATC_itemSize = "" & cStr(Request.Form("magecart_1_Size_Add")) & ""' column binding
  if (IsNumeric(ATC_itemQuantity) AND ATC_itemQuantity <> 0)     then
    set magecart = magecart_AddToCart(ATC_AddIfIn, ATC_RedirectIfIn, ATC_itemID, ATC_itemName, ATC_itemDescription, ATC_itemWeight, ATC_itemQuantity, ATC_itemPrice, ATC_itemColour, ATC_itemSize)
    if (ATC_RedirectAfter <> "" AND magecart_redirStr = "")     then
      magecart_redirStr = ATC_RedirectAfter
    end if
    Session("WAEC_ContinueRedirect") = cStr(Request.ServerVariables("Script_Name"))  & "?" & cStr(Request.QueryString())
  end if
end if
%>
<%
' WA eCart Redirect
if (magecart_redirStr <> "")     then
  Response.Redirect(magecart_redirStr)
end if
%>
<!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"><!-- InstanceBegin template="/Templates/master1.dwt.asp" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable --><!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="magicalrooms.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
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_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_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>
<!-- InstanceParam name="bag" type="boolean" value="true" --><!-- InstanceParam name="leftNav" type="boolean" value="true" --><!-- InstanceParam name="admin nav" type="boolean" value="false" --><!-- InstanceParam name="site nav" type="boolean" value="true" -->
</head>
<body onload="MM_preloadImages('img/images/wish_list_selected_03.gif','img/images/log_in_selected_03.gif','img/images/register_selected_03.gif','img/images/delivery_selected_03.gif','img/images/locator_selected_03.gif','img/images/help_selected_03.gif','img/images/voucher_selected_03.gif')">
<div id="container">
   
  <div id="banner">
    <div id="logo"></div>
      <!--#include file="keyword_search.asp" -->
      <div id="tabs"><img src="img/images/full_tabs_03.gif" name="fulltabs" width="467" height="23" border="0" usemap="#tab" id="fulltabs" />
        <map name="tab" id="tab">
          <area shape="rect" coords="2,2,56,21" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/wish_list_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="58,3,97,21" href="admin/log_in.asp" onmouseover="MM_swapImage('fulltabs','','img/images/log_in_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="99,3,146,21" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/register_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="149,3,196,23" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/delivery_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="200,3,316,22" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/locator_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="319,5,350,22" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/help_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
          <area shape="rect" coords="355,5,455,21" href="#" onmouseover="MM_swapImage('fulltabs','','img/images/voucher_selected_03.gif',1)" onmouseout="MM_swapImgRestore()" />
        </map>
    </div>
  </div>

  <div id="mainpage">
    <div id="leftnav">
      <script type="text/javascript" language="JavaScript" src="Scripts/drop.js">
      </script>
     
      <!--#include file="nav.asp" -->
     
    <!--#include file="bag_display.asp"-->
    </div>
  <!-- InstanceBeginEditable name="contentarea" --><div id="content">
     
      <div id="detailImages">
        <p><img src="download_detail.asp?id=<%=(RsImageFeatured.Fields.Item("Image").Value)%>&amp;Width=150" alt="<%=(RsImageFeatured.Fields.Item("ProdName").Value)%>" hspace="5" vspace="5" border="0" align="center" />   </p>
        <p>
        <table>
          <%
startrw = 0
endrw = HLooper1__index
numberColumns = 2
numrows = -1
while((numrows <> 0) AND (Not RsImages.EOF))
      startrw = endrw + 1
      endrw = endrw + numberColumns
 %>
          <tr align="center" valign="top">
            <%
While ((startrw <= endrw) AND (Not RsImages.EOF))
%>
            <td><img src="download_detail_thumbs.asp?id=<%=(RsImages.Fields.Item("Image").Value)%>&amp;Width=70" alt="<%=(RsImages.Fields.Item("ProdName").Value)%>" hspace="5" vspace="5" border="0" align="center" /> </td>
            <%
      startrw = startrw + 1
      RsImages.MoveNext()
      Wend
      %>
          </tr>
          <%
 numrows=numrows-1
 Wend
 %>
        </table>
      </div>
       <div id="detailDetails">
        <br />
<h1><%=(RsDetail.Fields.Item("ProdName").Value)%></h1>
        <p><%=(RsDetail.Fields.Item("ProdLongDesc").Value)%>              </p>
      </div>
       
      <div id="addtobag">
        <p>Choose your required colour and size and select a quantity:</p>
        <form name="magecart_1_ATC_<%=RsDetail.Fields("ProdID").value%>" method="POST" action="<%=cStr(Request.ServerVariables("SCRIPT_NAME"))%><%=WA_eCart_IIf((Request.ServerVariables("QUERY_STRING") <> ""), "?" & Request.ServerVariables("QUERY_STRING"), "")%>">
          <input type="hidden" name="magecart_1_ID_Add" value="0" />
          <input type="hidden" name="magecart_1_Name_Add" value="<%=(RsDetail.Fields.Item("ProdName").Value)%>" />
          <input type="hidden" name="magecart_1_Description_Add" value="<%=(RsDetail.Fields.Item("ProdShortDesc").Value)%>" />
          <input type="text" name="magecart_1_Quantity_Add" value="1" size="4" />
          <% If (RsColour.Fields.Item("CountOfProdAvailColour").Value)>= 2 Then %>
                 <select name="magecart_1_Colour_Add" id="magecart_1_Colour_Add">
                   <%
While (NOT RsColourName.EOF)
%><option value="<%=(RsColourName.Fields.Item("AvailColourName").Value)%>"><%=(RsColourName.Fields.Item("AvailColourName").Value)%></option><%
  RsColourName.MoveNext()
Wend
If (RsColourName.CursorType > 0) Then
  RsColourName.MoveFirst
Else
  RsColourName.Requery
End If
%>
</select>
      <% Else %>
      <input name="magecart_1_Colour_Add" type="hidden" value="<%=(RsDetail.Fields.Item("AvailColourName").Value)%>" />
      <% End If %>
      <% If Not(RsDetail.Fields.Item("SizeName").Value) = "None" Then %>
                      <select name="magecart_1_Size_Add" id="magecart_1_Size_Add">
             <%
While (NOT RsDetail.EOF)
%>
             <option value="<%=(RsDetail.Fields.Item("SizeName").Value)%>"><%=(RsDetail.Fields.Item("SizeName").Value)%></option>
             <%
  RsDetail.MoveNext()
Wend
If (RsDetail.CursorType > 0) Then
  RsDetail.MoveFirst
Else
  RsDetail.Requery
End If
%>
</select>
                    <input type="hidden" name="magecart_1_Price_Add" value="<%=(RsDetail.Fields.Item("Price").Value)%>" />
                    <% Else %>
      <input name="magecart_1_Size_Add" type="hidden" value="<%=(RsDetail.Fields.Item("SizeName").Value)%>" />
      <% End If %>
          <input type="image" src="WA_eCart/Images/Pacifica/Btn2_EN_addtocart.gif" border="0" value="Add to Cart" name="magecart_1_ATC">
        </form>
        <p><br />
        </p>
      </div>
      <br />
      </p>
     
  </div>
    <!-- InstanceEndEditable --></div>
<div class="footer" id="footer"><a href="page.html">How To Find Us</a>  <a href="page.html">Terms  &amp; Conditions</a>  - <a href="page.html">Privacy
  Policy</a> - Returns - Links - Customer Feedback<br />
  &copy; Copyright Magical Rooms 2007</div>
</div></body>
<!-- InstanceEnd --></html>
<%
RsImageFeatured.Close()
Set RsImageFeatured = Nothing
%>
<%
RsImages.Close()
Set RsImages = Nothing
%>
<%
RsDetail.Close()
Set RsDetail = Nothing
%>
<%
RsColour.Close()
Set RsColour = Nothing
%>
<%
RsColourName.Close()
Set RsColourName = Nothing
%>
0
Comment
Question by:swordfishsoup
  • 9
  • 8
17 Comments
 
LVL 25

Expert Comment

by:Rouchie
ID: 20288134
Hi swordfishsoup

Can you point me to a live working version so I can see what's happening?  There's a lot of code here and I can't test it on my machine without all the rest of the application, so I'm struggling to see what the issue is!!
0
 

Author Comment

by:swordfishsoup
ID: 20288198
Hi Rouchie...good to see you again.

I'm working on localhost with this. But I'm sure I can explain it better than I did earlier.
So:

Say we have two products. a 'kite' one size - one colour and a teddy (good old teddy) small medium large and extra large. with respective prices of 2.00 - 4.00 - 6.50 - 10.00. All the deatils of which are being pullled from the recordset.

I have an 'add to cart' form on this page which IF (stment) there are multiple colours/sizes adds a menu list ELSE it doesn't and just adds a hidden field with the ID for None.

There is also a hidden field for price, but this needs to update when a size choice is made from the drop down...with me.

For fixed size products the hidden field is fine, when a choice is available the hidden field is still set at the first record out of the database so 'SuperTed' is only 2 quid...bargain!

This form sets a server variable that is placed in a cart row on the 'view cart' page. I just need some 'inbetween' element that resets the price to match the 'size id' in the menu list item that was selected and adds that to the sever variable. Some kind of set value after the post but before the variable is set.

I appreciate that this is difficult without a live version to see, so even a suggestion of how to approach this would be great.

Hope that makes more sense let me know and I'll see if I can get at least this part live for you to see.

Hope you're well and thanks

Dave

0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20289371
>> ...with me.

I think so.  Can you just post a screen grab of what you see when this options screen is loaded in your browser, so I can get a feel for how it works?
0
 

Author Comment

by:swordfishsoup
ID: 20290624
Hi

I have posted a series of screen shots here. Let me know if anything else is needed.

I really don't expect you try and code anything for this with no acces to the page, just a word of wisdom as to a potential aprroach would be great.

Thanks
link is: http://www.discburner.co.uk/rouchie.html
0
 

Author Comment

by:swordfishsoup
ID: 20296726
Hi
I think I must need to add another action to the add to bag form that looks up the price from tblPrice where prodID = ? size = ? and colour = ? and then the second part sets the server variables for adding into the cart display. Can I do that with a form? If so how to get these two elements to happen in the right order?

Does that sound like the right approach to you?

Thanks

Dave
0
 

Author Comment

by:swordfishsoup
ID: 20297129
STOP
Hi Rouchie.

I've cracked it. Was fairly straightforward in the end. I'll ost the code below. Was just a recordset for price based on Form variables for size and adding the price to the part that submits to the cart.

I'm sorry that was such a badly asked question.

Have a good one

DAve

if (cStr(Request.Form("magecart_1_ATC")) <> "" OR cStr(Request.Form("magecart_1_ATC.x")) <> "")     then

Dim RsPrice__ParamSizeName
RsPrice__ParamSizeName = "Age 8"
If (Request.Form("magecart_1_Size_Add") <> "") Then
  RsPrice__ParamSizeName = Request.Form("magecart_1_Size_Add")
End If

Dim RsPrice
Dim RsPrice_cmd
Dim RsPrice_numRows

Set RsPrice_cmd = Server.CreateObject ("ADODB.Command")
RsPrice_cmd.ActiveConnection = MM_MagicalRooms_STRING
RsPrice_cmd.CommandText = "SELECT tblPrice.Price FROM tblSizeGroup RIGHT JOIN tblPrice ON tblSizeGroup.SizeGroupID = tblPrice.PriceSizeID WHERE (((tblPrice.PriceProdID)= ? ) AND ((tblSizeGroup.SizeName)= ?)) GROUP BY tblPrice.Price"
RsPrice_cmd.Prepared = true
RsPrice_cmd.Parameters.Append RsPrice_cmd.CreateParameter("param1", 5, 1, -1, RsPrice__ParamProdID) ' adDouble
RsPrice_cmd.Parameters.Append RsPrice_cmd.CreateParameter("param2", 200, 1, 255, RsPrice__ParamSizeName) ' adVarChar

Set RsPrice = RsPrice_cmd.Execute
' RsPrice_numRows = 0
'  RsPrice.Close()
'Set RsPrice = Nothing


  ATC_itemID = cStr(Request.Form("magecart_1_ID_Add"))
  ATC_AddIfIn = 0
  ATC_RedirectAfter = "bag.asp"
  ATC_RedirectIfIn  = ""
    ATC_itemName = "" & cStr(Request.Form("magecart_1_Name_Add")) & ""' column binding
    ATC_itemDescription = "" & cStr(Request.Form("magecart_1_Description_Add")) & ""' column binding
    ATC_itemWeight = cDbl("0")' column binding
    ATC_itemQuantity = "" & cStr(Request.Form("magecart_1_Quantity_Add")) & ""' column binding
    ATC_itemPrice = (RsPrice.Fields.Item("Price").Value) ' column binding
    ATC_itemColour = "" & cStr(Request.Form("magecart_1_Colour_Add")) & ""' column binding
    ATC_itemSize = "" & cStr(Request.Form("magecart_1_Size_Add")) & ""' column binding
  if (IsNumeric(ATC_itemQuantity) AND ATC_itemQuantity <> 0)     then
    set magecart = magecart_AddToCart(ATC_AddIfIn, ATC_RedirectIfIn, ATC_itemID, ATC_itemName, ATC_itemDescription, ATC_itemWeight, ATC_itemQuantity, ATC_itemPrice, ATC_itemColour, ATC_itemSize)
 
if (ATC_RedirectAfter <> "" AND magecart_redirStr = "")     then
      magecart_redirStr = ATC_RedirectAfter
    end if
    Session("WAEC_ContinueRedirect") = cStr(Request.ServerVariables("Script_Name"))  & "?" & cStr(Request.QueryString())
  end if
end if
 
%>
<%
' WA eCart Redirect
if (magecart_redirStr <> "")     then
  Response.Redirect(magecart_redirStr)
end if
%>
0
 
LVL 25

Accepted Solution

by:
Rouchie earned 500 total points
ID: 20297188
Well that's the first web page that's ever been named after me, lol...!

Okay my approach would be this...

Presuming that price changes with size and not with colour...I would always show the drop down menus regardless of whether size/colour information exists.  In addition I would have an extra field containing true/false that tells us if size/colour choices are available.  So, for kite you'd see this:

KITE  ----------------
Quantity  [ 1 ]
Colour     [n/a    â–¼]        (<--- crude drop down illustration!)
Size        [n/a    â–¼]
HiddenField [false]

ADD TO CART
-----------------------

The drop down fields might even be disabled in the above example as there's nothing to select anyway.


And for our old friend the teddy you'd see this:

TEDDY -----------------------------------
Quantity  [ 1 ]
Colour     [Red   â–¼]
               | Blue     |
               | Green  |
               -----------
Size        [Small £2.00   â–¼]
               |Medium £4.00   |
               |Large    Â£6.00   |
               |XLarge  Â£8.00  |
               --------------------
HiddenField [true]

ADD TO CART
-----------------------------------------

Now here's the trick.  The price text would be included with the size in the drop down.  That's easy because you're pulling it from the database anyway.   When ADD TO CART is pressed, we then make an extra database call using the values from the selection boxes and get the product details & price to add to cart.
So, here's the pseudo code:

If HiddenField = true then
   Select productsDetails, Price from Database where productID = ? AND colour = ? AND size = ?
   Add this data to cart
Else
   Select productsDetails, Price from Database where productID = ?
   Add this data to cart
End If
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20297191
Ouch that hasn't posted correctly.  The â–¼ is supposed to display as a down-arrow
I nicked that symbol from character map...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 25

Expert Comment

by:Rouchie
ID: 20297200
LOL

>> Was just a recordset for price based on Form variables for size and adding the price to the part that submits to the cart.

Yes that's pretty much what I tried to illustrate using text!!!
Send me a link to your site when it's live I want to see our old friend the teddy for real  ;-)
0
 

Author Comment

by:swordfishsoup
ID: 20297219
>>>Well that's the first web page that's ever been named after me, lol...!

You deserve it for putting up with the teddy bear for so long! :)

The way I did it in the end was very similar to your plan (which I've only just seen, so thanks for taking the trouble).

Next up ......Same principal can be used, I have to check the stock (remember that lovely stock table!) and either pop-up saying sorry fresh out of teddies or redirect to cart.

I think I'll be able to use this same technique for that. Will let you know.

PS: I would never have got this far without your and Jasons earlier help with querystrings, it's been a revolution for me.

Have a top day....I'll be back!
0
 

Author Comment

by:swordfishsoup
ID: 20297222
>>>>Send me a link to your site when it's live I want to see our old friend the teddy for real  ;-)

Certainly will! (I'm hoping it will be next week...aggghh)
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20297244
>> I think I'll be able to use this same technique for that.

Yes you will.  Alternatively also pull out the stock total when you grab the colour data.  So in the recordset you get

colour, price, stockTotal

Then check stockTotal before displaying the drop down menu.  If it's zero then don't show that option, or provide some alternate display.
0
 

Author Comment

by:swordfishsoup
ID: 20297262
Good thinking!
Thanks
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20297275
>> Good thinking!

It comes with experience!  In a few month's time I'm sure you'll be gunning for free membership by answering ASP questions!

My head hurts anyway, I'd hate to think how much your's is!  At least it's friday... :-)
0
 

Author Comment

by:swordfishsoup
ID: 20297313
:) hurts isn't the word....delirious is more like it, have query strings whizzing round my brain as I try and go to sleep!!

Although that is a top idea to not show drop downs when stock is out, i think I'll stick with the pop up offering the chice to choose again - or - add it to your 'wishlist' (yup that's next) encouraging sign ups and returns to the site. If I haven't completely lost the plot by the end of this it would be good to have an auto mail system so when stock is updated customers are mailed....Oh dear................
0
 
LVL 25

Expert Comment

by:Rouchie
ID: 20297356
>> it would be good to have an auto mail system so when stock is updated customers are mailed....
>> Oh dear................

All in a day's work!
0
 

Author Comment

by:swordfishsoup
ID: 20298111
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now