EDIT: This privately published page is what I need to work with. Password: stackOF
My client desires is to have her WordPress blog show a MailChimp form on her home page as a gateway to a .pdf. I need the following behavior to occur when the user clicks “Submit”:
- execute the included MailChimp’s javascript file; this ensures the form was properly filled, and then performs the sign-up to the newsletter list (don’t need help with this part)
- then show the user an informational PDF for download or viewing
EDIT: The logical order was flipped from when I originally posted this. The script should execute, and only if the script gets executed properly should the PDF show to the user
Note:
- My experience level with HTML and PHP is 3/4, and with JS I am 2/4 EDIT: (seems more like 1/4 at this point lol). If my research is correct, PHP (server-side language) would be used to do that which the client wants.
- Additional validation is not necessary beyond what MailChimp’s script provides (it ensures that user has submitted a completed form) in this case (the client says it’s ok if the e-mail isn’t valid at all).
- The .pdf URL and content is static, and simply needs to be shown, not generated.
—-RESEARCH—-
I know that the Mailchimp form uses the following line to actually submit the information, but I want to do the action mentioned below, as well as open the aforementioned .pdf:
<form action="http://*BLAH*.us2.list-manage.com/subscribe/post?u=*BLAHBLAH*&id=*BLAHBLAHBLAH*" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
I am reading on other sites that I can conceivably point “action” to a .php file, but if there is a way to do this with javascript – since its using the .js file that I created for that already anyways, then I would be most happy. Barring that, I’ll take what I can get..
You can try the following:
add an
onsubmithandler on the mailchimp form like below:Your javascript function:
Hope this helps.