Form to Email question

Discussion in 'ASP General' started by David, Oct 23, 2006.

  1. David

    David Guest

    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.
    David, Oct 23, 2006
    #1
    1. Advertising

  2. David

    Mike Brind Guest

    "David" <> wrote in message
    news:...
    > 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.

    --
    Mike Brind
    Mike Brind, Oct 23, 2006
    #2
    1. Advertising

  3. David

    David Guest

    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

    ------------------------------------------------------------------------------
    David, Oct 25, 2006
    #3
  4. David

    Mike Brind Guest

    "David" <> wrote in message
    news:...
    > 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.

    --
    Mike Brind
    Mike Brind, Oct 25, 2006
    #4
  5. David

    David Guest

    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
    David, Oct 25, 2006
    #5
  6. David

    Evertjan. Guest

    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Oct 25, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    0
    Views:
    3,328
    Peter
    Jul 1, 2003
  2. John Silver
    Replies:
    0
    Views:
    597
    John Silver
    Feb 4, 2005
  3. =?Utf-8?B?SnVzdGlu?=

    Problem Sending email form web form

    =?Utf-8?B?SnVzdGlu?=, Feb 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,482
    =?Utf-8?B?U2hhdW4=?=
    Feb 21, 2005
  4. Replies:
    1
    Views:
    679
    Randell D.
    Mar 17, 2005
  5. Replies:
    13
    Views:
    442
    Randy Webb
    May 14, 2006
Loading...

Share This Page