Form to Email question

D

David

Hi,

I have an asp page which I am designing.
On this page will be a set of records pulled from my db. These records
will be displayed within a form.
Each record will have a 'dropdown' displayed on the right hand side of
each record, so the user can select 'Approved' or 'Scrap' for each
seperate record.

I then want the user to be able to submit this form to us by email.
All I need to know is how to get the records with the selected answers
in the form into the body of the email ?

i.e.

Record1 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record2 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record3 > xxxxx yyyyy ffff rrrrrr 'Scrap'
Record4 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record5 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record6 > xxxxx yyyyy ffff rrrrrr 'Scrap'

Appreciate your help

Thanks


David.
 
M

Mike Brind

David said:
Hi,

I have an asp page which I am designing.
On this page will be a set of records pulled from my db. These records
will be displayed within a form.
Each record will have a 'dropdown' displayed on the right hand side of
each record, so the user can select 'Approved' or 'Scrap' for each
seperate record.

I then want the user to be able to submit this form to us by email.
All I need to know is how to get the records with the selected answers
in the form into the body of the email ?

i.e.

Record1 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record2 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record3 > xxxxx yyyyy ffff rrrrrr 'Scrap'
Record4 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record5 > xxxxx yyyyy ffff rrrrrr 'Approved'
Record6 > xxxxx yyyyy ffff rrrrrr 'Scrap'

The values of the "dropdown" (select lists) will be available in the
Request.Form collection. Put these in the body of your email.

For Each x in Request.Form
EmailBody = EmailBody & x & ": " & Request.Form(x) & "<br>" 'or vbCrLf
if text
Next

You will need to omit items that you don't want to include, such as the
submit button, from the collection within the loop.
 
D

David

Thanks Mike,

I cannot seem to get this working:

For Each x in Request.Form
EmailBody = EmailBody & x & ": " & Request.Form(x) & "<br>" 'or vbCrLf

Next

The select statement on the form is <select name=select> ............
What do I put in place of x ?
I need to print what is inside the form tags + the selected item in
each of the dropdowns.

Thanks again.

David

------------------------------------------------------------------------------
 
M

Mike Brind

David said:
Thanks Mike,

I cannot seem to get this working:

For Each x in Request.Form
EmailBody = EmailBody & x & ": " & Request.Form(x) & "<br>" 'or vbCrLf

Next

The select statement on the form is <select name=select> ............
What do I put in place of x ?
I need to print what is inside the form tags + the selected item in
each of the dropdowns.

How did you try to get it to work? What happened to suggest that it didn't
work?

The For... Next loop will iterate through the Form collection and print out
the name of the Request.Form item in place of x, and its value in place of
Request.Form(x). You don't need to substitute x with anything.

Trying doing Response.Write instead of "EmailBody=EmailBody &" to see what I
mean.
 
D

David

Mike,

1/ Is there any way to remove the 'Submit' value from the forms
collection, as it appears in the middle of my data which I am
submitting via email.

2/ Also, is there any way to ORDER the forms collection data. I have
dynamically given the <select> object a new name on each loop within my
form, but the results are not in any particular order. I have named
them '1' onwards, i.e. 2, 3, 4, 5

In my email, I get an order of , 2, 7, 6, 4, 8 etc .... each on their
own line

Appreciate your help

Thanks

David
 
E

Evertjan.

David wrote on 25 okt 2006 in microsoft.public.inetserver.asp.general:
1/ Is there any way to remove the 'Submit' value from the forms
collection, as it appears in the middle of my data which I am
submitting via email.

<%
for x = 1 to Request.Form.count()
if Request.Form.key(x) <> "Submit" then
Response.Write(Request.Form.key(x) & " = ")
Response.Write(Request.Form.item(x) & "<br>")
end if
next
%>

Not tested, see <http://classicasp.aspfaq.com/forms/how-do-i-iterate-
through-a-form-collection.html>

There are also clientside options, but they are off topic here.
2/ Also, is there any way to ORDER the forms collection data. I have
dynamically given the <select> object a new name on each loop within my
form, but the results are not in any particular order. I have named
them '1' onwards, i.e. 2, 3, 4, 5

There are lots of ways ordering a array.

Try:

Put the collectoion into an array.
Then use serverside Jscript sort()
In my email, I get an order of , 2, 7, 6, 4, 8 etc .... each on their
own line

This is an ASP NG, how you send your email under ASP [CDO, Jmail, etc.]
is completely at the merci of your programme.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top