SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2000
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FOR/NEXT Loop in ORDER?

    I am processing the variables from a form submission with a for/next loop. The problem is that the order of the variables are NOT written IN ORDER. Form field 1 prints fine but then it jumps to Form field 9 and then back to Form field 4 then to Form field 2, etc. IS there a way to process the form variables in a loop in ORDER? field 1, field 2, field 3, etc?

    Code:
    Dim myMail 
    Dim item
    dim message
    Set myMail = CreateObject("CDONTS.NewMail") 
    
    for each item in request.form
    message = message & item & ": " & request(item) & "<BR>"
    next
    
    HTML = HTML & "<B>The following " & request("formpurpose") & " request was entered at<BR>http://www.mywebsite.com/contactus.asp:<BR><BR>" 
    HTML = HTML & "<B>Please send reply to the customer's e-mail address below.</b><BR><BR>"
    HTML = HTML & message
    HTML = HTML & "<BR>Request Time: " & Now()
    HTML = HTML & "<BR>" 
    myMail.From = "Webmaster@mywebsite.com"
    myMail.To = "alexming@somewebsite.com" 
    myMail.Subject = request("formpurpose")
    myMail.BodyFormat = 0 
    myMail.MailFormat = 0 
    myMail.Body = HTML 
    myMail.Send 
    response.redirect("thankyou.asp")
    ANY hints would be appreciated.

    Thank you.

  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can always hard code the form values in the order you want them to appear.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2000
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know but that defeats the purpose of the loop... suppose there were 50 form inputs and 10 different contact forms?

    I hope someone can answer this because I really don't want to hard code that.

    Thanks

  4. #4
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Loop through like this...

    Code:
    For c = 1 To Request.Form.Count
    	fName = Request.Form.Key( c )
    	fValue = Request.Form( c )
    Next
    and it should appear in order,
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  5. #5
    SitePoint Addict
    Join Date
    Aug 2000
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you... works like a charm.

  6. #6
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most welcome...
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •