[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need help creating cfmail with information gathered via cfloop

Posted on 2006-06-05
3
Medium Priority
?
233 Views
Last Modified: 2006-11-18
<CFLOOP From = "1" TO = "#ListLen(FieldList)#" INDEX = "Counter">
    #ListGetAt(FieldList, Counter)#
      #evaluate('form.'&listgetat(fieldlist,counter))#
</CFLOOP>

Hello Experts,

Just a little background on what I am up to:

I have a page that requests various bits of information, i.e. Customer name, address, tel#, etc. Further down the page, the user is asked for a series of customer names, and even further down a sort of agenda. After the user fills in the info, he selects "submit" and is sent to page 2.

Page 2: The user "checks" this data to make sure all his names are spelled correctly, times are right, et. etc. After the user is sufficiently satisfied with his accuracy, the user clicks "forward e-mail" (submit). The form is posted to itself, and an email is sent. I have the bit of code (above) harvesting the information from the original page2 and sending it out via e-mail.


Here's my dilema: I need to format the email to be neat and tidy. Right now, the email arrives with the information in a two column table. It needs to look like this -

-----------------------------------------------------------------

Customer:     Country Bumpkins Store
Address:       123 Anywhere St., Anythown USA 12345
Phone:          555-123-4567

Visitors
John Doe               Owner
Jane Doe              Co-Owner
William Roberts     Facilitator

Locations to Visit:
Processing Center, Sales Center, IT


FROM        TO            AGENDA
0800          0900         Tour Sales Facility
0900          1000         Tour Processing Center
1000          1100         Tour IT facility
1100          1200         Lunch with customers

----------------------------------------------------------

At this point I can just create rudimentary tables, but as you can see, there is quite a bit of formatting that needs to be done. I thought about having 2-3 loop conditions, harvesting fields by a portion of their field names, i.e. agendato1, agendafrom1, agenda1, agendato2, agendafrom2, agenda2 etc, rather than just doing a blanket fieldame collection.

I apologize for the length of the question, but wanted to be as thorough as posible and give you all the information.




0
Comment
Question by:CementTruck
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 16835551
Well doing it by a coolection of fieldnames is a very clunky poor way to go.  The only reason you would do that is if you did not know any of the fieldnames because the email content was dynamic in what fields would be included.  In that case you can't format since you don't know what will be there or what it should look like.

Assuming you do know the fields - even is sometimes some are optional - then you should access by name.  Then you can format like:

Customer:    #CustomerName#
Address:      #CustomerAddress#
Phone:        #CustomerPhone#

Visitors
<cfloop index="i" from="1" to="#FOrm.VisitorCount#">
#Form["VisitorName" & i]#     #Form["VisitorPosition" & i]#
</cfloop>

etc...
0
 

Author Comment

by:CementTruck
ID: 16835728
mrichmon,

I'm glad you answered. I've always had good luck with your suggestions.

Normally, I would do what you are suggesting, but am having trouble passing the variables once I'm on page2, and submitting to itself after the user checks his spelling, etc.. I can get the variables to pass from page1 to page2, but from page2 to page2 eludes me. If you could help me out with that, then I believe I'll be out of the woods. I didn't want the form variable to become session variable because I wanted them to only be used this one time, and after the submission of the form I no longer needed them. This keeps me from having to struct delete, etc.

I am open to suggestions, as I will always be a newbie to this. It won't be long before I get used to CF and someone in a position higher than myself decides to go another route. i.e. ASP, to CF, to "whatever". AJAX is the new buzzword around here. Forgive the ignorance and duplication of questions.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 16835771
You can assign the variables to hidden variables.

You can also assign to the form object itself, I forget the exact syntax.

However, you must be doning it someway now.  You could still use that method and then just search the list of the field you want at a given time.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Suggested Courses
Course of the Month19 days, 10 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question