Happy Monday afternoon Squiz peoples.
I noticed no-one has posed a question since my last question on Friday, so I thought I'd get in early and get your brains fired up for a super week ahead.
Here's what I need to do:
I currently have a bunch of documents on my site. Each document has a landing page, with a bit of info about the document and a link to the asset (pdf). On clicking the link instead of giving the user the PDF straight away, I'd like to pop open a small form that asks the user if it's OK if we contact them in a few weeks to find out how they used the document they downloaded. The form would two text fields, name; email, and two buttons, yes, and no thanks. On clicking yes, the form details are submitted and the PDF is presented. On clicking no, the blank form is submitted, or I could nest a "no only" form under the "yes form", and the PDF is served. I'll be putting the pop-up action on the original document hyperlink on about 20 different documents, so I only want to build one form. So effectively I'm wanting to send the PDF URL to the form and store in a hidden field, and then somehow (maybe the form action) on form submit, send the user to the PDF?
Hope I've explained myself.
Cheers again
Pass variable to one or more pages - how to?
I have done something like this in the past for PUC.
What I did was use jQuery and the ajax method that will allow you to post form fields to the custom form. So, if the user clicked yes, the ajax method would be called, posting the data to the form (which you have built but not nested), once the submit completes, the completed callback would fire, and at that point, you could pull in the PDF url and redirect the user.
Should be pretty easy.
That's great Nic
I kinda tried to stay close to your suggestion and managed to get it working no problem (bit of a hack job but it works).
I created a hidden form field and used a simple jquery to grab the param ("name") from my URL. So my hyperlink looks something like: mysite/custom-form/?name=mypdf.pdf
The hidden field stores the the PDF name and on submit, the PDF URL is passed to the thankyou page where I have a simple JavaScript redirect which opens the PDF to the PDF URL passed to it.
Because the PDF URL is also submitted in the form means I get to track which PDF (out of 20) that people are downloading. Bonus.
Thanks again Nic