...

View Full Version : ASP Help Needed: Shopping Basket



shaunio
10-29-2003, 11:11 AM
I am designing a site for a mock music store... i am an absolute beginner and any help would be greatly appreciated!

there is a page, catalogue1.asp in which there is a drop-down menu which displays the Release titles from the database (Choose a release and it gives back the corresponding information) into the same page, catalogue1.asp.

I want to add a shopping basket, and this is where I am muddled up... I simply want a text box in which the quantity of CD's can be entered, and then submitted with a form into the database. I want this page to then direct to a page basket.asp where the user then enters their personal information and it is put into the database. Sounds easy!

My problem is that the catalogue navigation is done with the field 'Release' from the database (ausreleases). I want to use another field 'relId' to add the items to the basket (because this has a relationship with a primary key in the database). But at the same time, I still want to be able to navigate using the Release titles in the drop-down menu (makes it much easier for navigation).

I just want them both to work at once, if anyone could help that would be fantastic, the source code for catalogue1.asp is below.

<% 'Declare connection variable, then create connection
dim conn
set conn = Server.CreateObject("ADODB.connection")
conn.open "ausreleases"
%>

<%
If Request.Form("BuyButton") = "Buy Now" Then

'-- Add item to shopping cart
OrderItem = Request.QueryString("OrderItem")

Set RSAus = Server.CreateObject("ADODB.Recordset")
SQL="SELECT * FROM ausreleases WHERE OrderNo='" & Session("OrderNo") _
& "' AND relId='" & relId & "'"
RSShopCart.Open SQL, 1,3,1
If RSAus.EOF Then
RSAus.AddNew
RSAus.Fields("OrderNo") = Session("OrderNo")
RSAus.Fields("relId") = relId
RSAus.Fields("OrderDate") = Date
'I don't know how to do the quantity.. I want the user to submit the quantity of their choice into the form at the bottom of the page
RSAus.Fields("OrderQuantity") = 1
RSAus.Update
End If
RSAus.Close

Response.Redirect("basket.asp")

End If
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Filler: Australian Punk Rock Distribution</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="JavaScript" type="text/JavaScript">
<!--
// Preload main images
if(document.images)
{
var heading= new Image();
heading.src="images/heading copy.gif";
var stockholm= new Image();
stockholm.src= "images/stockholm02.jpg";
}
// Preload and rollover menu
if(document.images)
{
// Preload original Images
var home_init= new Image();
home_init.src="images/Home copy.gif";
var catalogue_init= new Image();
catalogue_init.src="images/catalogue.gif";
var basket_init= new Image();
basket_init.src="images/shoppingbasket.gif";
var about_init= new Image();
about_init.src="images/aboutus.gif";

//Preload rollover-state images
var home_roll= new Image();
home_roll.src="images/Home copy_rollover.gif";
var catalogue_roll= new Image();
catalogue_roll.src="images/catalogue_rollover.gif";
var basket_roll= new Image();
basket_roll.src="images/shoppingbasket_rollover.gif";
var about_roll= new Image();
about_roll.src="images/aboutus_rollover.gif";
}

function change_it(the_name)
{
if (document.images)
{
document.images[the_name].src= eval(the_name + "_roll.src");
}
}
function change_back(the_name)
{
if (document.images)
{
document.images[the_name].src= eval(the_name + "_init.src");
}
}


// Attempt at making navigation form 'chooseRelease' work
document.chooseRelease.relSelect.options[document.chooseRelease.relSelect.selectedIndex].value;

//-->
</script>
</head>

<body onLoad="var SymTmpWinOpen = window.open; window.open = SymWinOpen; MM_preloadImages('../../Inetpub/webpub/images/Home%20copy_rollover.gif','../../Inetpub/webpub/images/catalogue_rollover.gif','../../Inetpub/webpub/images/shoppingbasket_rollover.gif','../../Inetpub/webpub/images/aboutus_rollover.gif'); window.open = SymTmpWinOpen">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#D9F2FF">
<tr>
<td height="164"><img src="../../Inetpub/webpub/images/heading%20copy.gif" width="800" height="164"></td>
</tr>
<tr>
<td align="left" valign="top"> <table style="padding-right: 10px" width="214" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><img src="../../Inetpub/webpub/images/llepose.jpg" width="214" height="228"></td>
</tr>
<tr>
<td><a href="../../Inetpub/webpub/index.html" onMouseOver="change_it('home')" onMouseOut="change_back('home')"><img src="../../Inetpub/webpub/images/Home%20copy.gif" name="home" width="214" height="17" border="0" id="home"></a></td>
</tr>
<tr>
<td><a href="../../Inetpub/webpub/catalogue.asp" onMouseOver="change_it('catalogue')" onMouseOut="change_back('catalogue')"><img src="../../Inetpub/webpub/images/catalogue.gif" name="catalogue" width="214" height="17" border="0" id="catalogue"></a></td>
</tr>
<tr>
<td><a href="../../Inetpub/webpub/basket.asp" onMouseOver="change_it('basket')" onMouseOut="change_back('basket')"><img src="../../Inetpub/webpub/images/shoppingbasket.gif" name="basket" width="214" height="17" border="0" id="basket"></a></td>
</tr>
<tr>
<td><a href="../../Inetpub/webpub/aboutus.html" onMouseOver="change_it('about')" onMouseOut="change_back('about')"><img src="../../Inetpub/webpub/images/aboutus.gif" name="about" width="214" height="17" border="0" id="about"></a></td>
</tr>
<tr>
<td><img src="../../Inetpub/webpub/images/stalbans.jpg" width="214" height="228"></td>
</tr>
<tr>
<td><img src="../../Inetpub/webpub/images/crowd.jpg" width="214" height="228"></td>
</tr>
</table>
<table width="577" height="500" border="0" cellpadding="2" cellspacing="0">
<tr>
<td><h1><font face="Rockwell Condensed">Catalogue</font></h1>
<p>Select a title to view its details and price.</p>

<!-- Start DB table here -->
<table border=1 cellspacing=0>
<%
set conn=server.createobject("ADODB.connection")
conn.Open "driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("ausreleases.mdb")
sql = "SELECT * FROM [Releases]"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn
%>
<form method="get" action="catalogue1.asp">
<select name="lstRel" size="1">
<%
Do while not RS.EOF
response.write "<option value='" & rs("Release") & "'>"
response.write RS("Release") & "</option>"
RS.movenext
loop
RS.close
set RS=nothing
%>
</select></p>
<p><input type="submit" name="submit" value="View Release"></p><br>
</table>

<table border=1 cellspacing=0>
<%
varTitle= request.querystring("lstRel")
Set orp=server.createobject("ADODB.recordset")
sqltext="Select * from Releases WHERE Release = " & "'" & varTitle & "'" & ";"
response.write "<p> Title Searched: <b>" & varTitle &"</b>"
orp.open sqltext, "driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("ausreleases.mdb")

response.write "<p>Information About This Release:<br>"
response.write "<p>Description: <b><br>" & orp("Description") & "</b><br>"
response.Write "<p><img src='" & orp("Image") & "'>"
response.write "<p>Format: <b>" & orp("Format") & "</b><br> "
response.write "</b><br>"
response.write "<p>Price: <b>" & "$" & orp("Price") & "</b><br>"
response.Write "<p>Label: <b>" & "<a href=""" & orp("LabelURL") & """>" & orp("Label") & "</a>"

' change that orp (?!) to rs (for recordset)
%>


<form action="../../Inetpub/webpub/catalogue1.asp?lstRel=<%=varTitle%>" method="post">
Qty
<input style="width: 30" name="Qty" type="text" id="Qty">
<input type="submit" class="buttonL" name="Buy" value="Buy Now">
<input name="relId" type="hidden" id="relId" value="5">
</form>


<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>

</html>

jeskel
10-29-2003, 06:08 PM
Hi, welcome...

here is what you'll have to do to get the quantity filled in by your user:


<%
If Request.Form("BuyButton") = "Buy Now" Then

dim OrderQuantity
OrderQuantity = request.form("Qty")



'-- Add item to shopping cart
OrderItem = Request.QueryString("OrderItem")

Set RSAus = Server.CreateObject("ADODB.Recordset")
SQL="SELECT * FROM ausreleases WHERE OrderNo='" & Session("OrderNo") _
& "' AND relId='" & relId & "'"
RSShopCart.Open SQL, 1,3,1
If RSAus.EOF Then
RSAus.AddNew
RSAus.Fields("OrderNo") = Session("OrderNo")
RSAus.Fields("relId") = relId
RSAus.Fields("OrderDate") = Date
'I don't know how to do the quantity.. I want the user to submit the quantity of their choice into the form at the bottom of the page
RSAus.Fields("OrderQuantity") = OrderQuantity
RSAus.Update
End If
RSAus.Close

Response.Redirect("basket.asp")

End If
%>

...

<form action="../../Inetpub/webpub/catalogue1.asp?lstRel=<%=varTitle%>" method="post">
Qty
<input style="width: 30" name="Qty" type="text" id="Qty">
<input type="submit" class="buttonL" name="Buy" value="Buy Now">
<input name="relId" type="hidden" id="relId" value="5">
</form>


hope it will work, and if yes, that it will help you...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum