1

I have a form that consists of several pages. Each pages saves the data to localStorage. The final page needs to pull the data from localStorage so that it can be emailed.

How can I get the data stored in localStorage in a format that can be emailed?

Currently, I am updating ID with the content stored in localStorage but the updates are occurring after the page is rendered so the cfsavecontent isn't realizing the text updates.

I need another way to do it and am open to suggestions, please.

HPWD
  • 2,232
  • 4
  • 31
  • 61
  • 2
    What do you have stored and how would you like to format it? Once you can answer this question, it should be pretty easy for you to format it the way you want. – Fabrício Matté Jan 16 '13 at 02:05
  • `first_name=John&middle_name=T.&last_name=Doe&mobile_phone=(219)+555-1234&home_phone=(219)+555-1235&email_address=jd123%40msn.com&address=123+Main+Street&city=Denver&state=CO&zip=90210`. – HPWD Jan 16 '13 at 02:56
  • Mhm, I usually store my data in JSON format but seems like you've stored it in some kind of `x-www-form-urlencoded` format.. That will require some parsing such as http://stackoverflow.com/a/1404100/1331430 – Fabrício Matté Jan 16 '13 at 03:01
  • I used jquery to serialize the form data for each page. I'm open to saving as JSON format but I wasn't sure how to save it. I'll read the link you provided. – HPWD Jan 16 '13 at 03:05
  • What if I performed an ajax call to get the localStorage data and then populated an ID on the current page? – HPWD Jan 16 '13 at 03:07
  • 1
    The link I provided was to help you parse what you currently have stored, but if you're open to use JSON then I'd suggest the [serializeJSON plugin](https://github.com/marioizquierdo/jquery.serializeJSON). `serializeJSON`, despite the name, returns an object so you have to stringify it with `JSON.stringify()` before storing (I believe it'd be automatically stringified, but better be safe) and parse it with `JSON.parse()` after retrieving from localStorage. I'm not good with coldfusion so I can't really help you in that part. – Fabrício Matté Jan 16 '13 at 03:13

1 Answers1

0

If you are able to collect the data, you can use js or jquery to post it as a string to another ColdFusion page. My preference is one inside a very small iframe.

Once you have it back into CF you can use urldecode() to restore the plain text and process it as you see fit. This,

first_name=John&middle_name=T.&last_name=Doe&mobile_phone=(219)+555-1234&home_p‌​hone=(219)+555-1235&email_address=jd123%40msn.com&address=123+Main+Street&city=De‌​nver&state=CO&zip=90210.

looks like nested lists to me. The outer delimiter is "&" and the inner is "=". The details depend on what you want the email to look like.

Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43
  • I'm using jQuery to loop and assign the values to the necessary fields. I like the iframe idea. – HPWD Jan 16 '13 at 04:00