|
|
|
7i24.Com不停为您服务 同时订购多样物品的源程序
This example was requested from one of our visitors where they wanted
to automatically create a PO of selected items from a list of
products from a database. The important thing about this example is
how to accurately capture the ID and Quantity of each item so you can
store it in the database correctly.
<!--#include virtual="/includes/openconnection.asp"-->
<%
If Request.Form.Count > 0 Then
Set rsBook = Server.CreateObject("ADODB.Recordset")
For I = 1 to Request.Form.Count
Quantity = Trim(Request.Form.Item(I))
If IsNumeric(Quantity) Then
ASIN = Right(Request.Form.Key(I),Len(Request.Form.Key(I))-
4)
'this example only displays the results back to the
browser
'this is where you could write the Ordered Items to the
database
'or create a PO.
cmdTemp.CommandText = "SELECT ASIN, Title FROM Books
WHERE ASIN = '" & ASIN & "'"
rsBook.Open cmdTemp, , 0, 1
If NOT rsBook.EOF Then Response.Write Quantity & " - " &
rsBook("Title") & " " & vbCRLF
rsBook.Close
End If
Next
Set rsBook = Nothing
Response.End
End If
%>
<HTML>
<HEAD><TITLE>Ordering Multiple Products as the Same
Time</TITLE></HEAD>
<BODY>
<form action="<%= Request.ServerVariables("SCRIPT_NAME") %>"
method=post>
<table>
<tr>
<th>Quantity</th>
<th>Title</th>
</tr>
<%
Set rsBooks = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT TOP 20 ASIN, Title FROM Books ORDER
BY PublicationDate DESC"
rsBooks.Open cmdTemp, , 0, 1
Do Until rsBooks.EOF
%>
<tr>
<td><input type=text size=2 name=Book<%= rsBooks("ASIN")%
>></td>
<td><%= rsBooks("Title") %></td>
</tr>
<%
rsBooks.Movenext
Loop
rsBooks.Close
Set rsBooks = Nothing
%>
</table>
<p>
<input type=submit value="Checkout">
</form>
</BODY>
</HTML>
<!--#include virtual="/includes/closeconnection.asp"-->
|
|
|