Hello,
I have a content site. On this site a user can select a peice of content then have it e-mailed to there e-mail address. Then they continue the process for each item they wish to have e-maile dto them.
My question is. If i want them to be able to batch select the items they want to recieve instead of 1 at a time, would I have to go about this with a shopping cart routine? or is there a simpler way that I am just over looking?
Thanks in advance,
G
7 1437
Hi there,
I'd suggest storing the list of items in an array. Once they have finished selecting items the entire contents of the array could then be e-mailed.
Does this help?
Dr B
No it wouldn't have to be a shopping cart, though it may look like some shopping carts, asthetically speaking.
There are many solutions for any problem, and since I don't know a whole lot about how you've set this up, i'll give you one suggestion.
Providing that you have your descriptions set up in a row based table in your database, I would have a checkbox system with a form post. Allow the user to check of each item they would like info regarding, and then provide a button at the bottom "Email me the info!"
1. Create your checkboxes with a unique identifier attached to them. -
<input type="checkbox" name="bSelected<% =oRs("ID") %>" value="true" />
-
Where oRs("ID") = the auto-increment field in your database table for the description of the item.
2. After the form has posted.. parse the information you recieve. Pass each of the IDs into your recordset to pull the information for each of the Items, loop through the recordset and create an email body of the information in which to send the user, pertinent to their choices. -
For Each oItem In Request.Form
-
If InStr(oItem,"bSelected") > 0 And CBool( Request.Form( oItem ) ) = True Then
-
sTemp = sTemp & Replace( Request.Form( oItem ), "bSelected", "") & " "
-
End If
-
Next
-
'sTemp will now be a string of all the IDs of the user's selection separated by a space so we can parse them into an array easily.
-
aTemp = Split( sTemp )
-
sSQL = "SELECT * FROM [tblDescriptions]"
-
If IsArray( aTemp ) Then
-
For i = 0 To UBound( aTemp )
-
If i = 0 Then
-
sSQL = sSQL & " WHERE ID = " & CInt( aTemp( i ) )
-
Else
-
sSQL = sSQL & " OR ID = " & CInt( aTemp( i ) )
-
End If
-
Next
-
ElseIf aTemp <> Empty Then
-
sSQL = sSQL & " WHERE ID = " & CInt( aTemp( i ) )
-
End If
-
Set oRs = Server.CreateObject("ADODB.RecordSet")
-
oRs.Open sSQL, Your_Connection, adOpenStatic, adLockOptimistic, adCmdText
-
Do Until oRs.EOF = True
-
sMessage = sMessage & oRs("sTitleOfItem") & VbCRLF
-
sMessage = sMessage & "The Item information goes here..."
-
oRs.MoveNext
-
Loop
-
oRs.Close
-
Set oRs = Nothing
-
3. Create your mailer object, set the subject, from address, to address, set the message into the body, and send the email.
Hope this gives you some insight.
Sincerely,
Mark
Thanks for the insight Mark,
My site is comprised entirely of XSL/XML .ASP. no SQL.
G.
No problem.
The same could be adapted to parse an XML document and send the info from it. And for that matter, .csv or even .txt or .xls files could be used to hold the information and parsed to send the required info... Or you could even just hold all the descriptive information within the .asp file and parse through a bunch of variables which hold that information - wouldn't recommend that, but it's possible. Probably the easiest way would be to create an access database to work off of, but if you'd prefer xml or some other method that's fine too.
Like I said, lots of ways to do it. If you want coding examples for any of the options above i'd be happy to oblige.
Sincerely,
Mark
Examples would be much apreciated. Using XML XSL ASP
G.
I'm sure I don't have to explain how to write an XML document, but just for the sake of sakes (and other viewer's information/education)..
1) the .xml document -
<document>
-
<message>some message</message>
-
<message>some message</message>
-
<message>some message</message>
-
</document>
-
2) The page to display the selections to the user -
<%
-
Set oXML = Server.CreateObject("msxml2.DOMDocument")
-
oXML.async = true
-
oXML.Load(Server.MapPath("/path/to/doc.xml"))
-
Set oMessages = oXML.DocumentElement.GetElementsByTagName("message")
-
For i = 0 To oMessages.Length - 1
-
%>
-
<input type="checkbox" name="bSelected<% =i %>" value="true" />
-
<!-- do whatever else you need to do, maybe some descriptive message, or wrap this inside table tags, etc.
-
<%
-
Next
-
%>
-
3) Parse the information, retrieving the message node information according to what the user chose -
For Each oItem In Request.Form
-
If InStr(oItem,"bSelected") > 0 And CBool( Request.Form( oItem ) ) = True Then
-
sTemp = sTemp & Replace( Request.Form( oItem ), "bSelected", "") & " "
-
End If
-
Next
-
'sTemp will now be a string of all the IDs of the user's selection separated by a space so we can parse them into an array easily.
-
aTemp = Split( sTemp )
-
'open the XML document and retrieve our list of message nodes
-
Set oXML = Server.CreateObject("msxml2.DOMDocument")
-
oXML.async = true
-
oXML.Load(Server.MapPath("/platform/platform.xml"))
-
Set oMessages = oXML.DocumentElement.GetElementsByTagName("message")
-
'Loop through the aTemp array, grabbing the information from the node as per the selections from the user which are numerical values held within the array. The numerical numbers represent the index of the message node within the xml document.
-
If IsArray( aTemp ) Then
-
For i = 0 To UBound( aTemp )
-
sEmailBody = sEmailBody & oMessages.Item( aTemp( i ) ).Text & VbCRLF
-
Next
-
ElseIf aTemp <> Empty Then
-
sEmailBody = oMessages.Item( aTemp( i ) ).Text
-
End If
-
Set oXML = Nothing
-
Hope that helps guide you in the right direction.
Sincerely,
Mark
Hi Mark,
Thanks for the example, I'll test a few ideas using your meothods today. The xml doc example wasn't required but I'm sure someone will find it useful. :)
Thanks again,
G.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Moosebumps |
last post by:
So, after reading some messages about os.system, and looking at the popen
stuff and trying it a bit, I still have not found a way to keep a command
window open for several commands (on Windows...
|
by: Bill |
last post by:
I need help closing a CMD window when it is executed from Access.
1) The batch file is called from Access.
2) Access closes,
3) the batch runs a copy of the access database (creating a backup)...
|
by: Charles Neitzel |
last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C#
2005 Express) that is nothing more than a simple UI with buttons on it. The
buttons do various things like running...
|
by: Charles |
last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual
C#
2005 Express) that is nothing more than a simple UI with buttons on it.
The
buttons do various things like running...
|
by: Blippy |
last post by:
I want to create a small look up program that searches for a certain
date and the batch number that is represented by that day. For instance
if i wanted to find the batch for 20/08/05 i would...
|
by: emman_54 |
last post by:
Hi every one,
I am trying to run a batch file using my asp.net application.
I am using the Process class to run the batch file. When I run my web
application, In the task manager, i could see...
|
by: Crash |
last post by:
Hi,
..NET v1.x SP1
VS 2003
SQL Server 2000 SP3
Server 2000, XP, Server 2003
I would like to programmatically execute {possibly many} SQL Server
batch scripts. Aka I have many scripts that...
|
by: tojigneshshah |
last post by:
Hi,
I have a situation where i have multiple batch and the each batch are
sequence numbers. For each batch, the number should start with 1.
For example:
Col.no1 Col.no2
------ ...
|
by: ck9663 |
last post by:
hi guys this is a little challenging, at least for me...here goes...
i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a...
|
by: =?Utf-8?B?R2lkaQ==?= |
last post by:
Hi,
In my windows applicationm, i need to excute a batch file.
this batch file throws some text and questions to the screen, i need to
catch the standard Output, check if it's a question, in...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |