0

The client has a section of her site that is not navigable through any other pages. To get to these pages she wants the user to fill out this form. It's a non-for-profit, so she basically just wants to see how many people are getting to these pages that have a product available for free so she can report on that. So there is a page with a form. She wants the user to submit the form and then be re-directed to another page. Normally I would do this really easily with PHP but unfortunately she hosts the site through some local fools and they don't support PHP

So the question is, how do I get this form to submit to her email, then redirect to a different page (videos.html) from the current page with the form (video-form.html)?

I have this form:

        <form id="myForm" action="mailto:mail@mail.net" method="post" name="VideoFormAction">
            <table cellspacing="1" cellpadding="1" width="46%">
                <tr>
                    <td valign="top" class="shade1"><font color="red"><b>*</b></font> Email Address</td>
                    <td valign="top"><input type="text" name="Mail" value="" size="30"></td>
                </tr>

                <tr>
                    <td valign="top" class="shade2">Name</td>
                    <td valign="top"><input value="" name="Name" type="text" size="30" maxlength="100"></td>
                </tr>

                <tr>
                    <td valign="top" align="center">
                        <font color="red"><b>*</b></font> = required field
                    </td>
                    <td valign="top">
                        <button class="button">Submit</button>
                    </td>
                </tr>
            </table>
         </form>

I have tried some javascript:

<script>
document.getElementById("myForm").onsubmit = function() {
    setTimeout(function(){
        window.location.href = "http://www.funducate.net/videos.html";  
    }, 1);
};
</script>

Which for whatever reason will not work. I have found multiple suggestions through search to try many different variations of the above, all of which failed. The last ditch effort was even putting a timeout into it as you see above. I imagine it doesn't work because the submit button performs the action="" and then doesn't continue.

Are there any other alternatives? Remember, I can't use PHP (i know it's ridiculous but it's what I got)

Michael
  • 7,016
  • 2
  • 28
  • 41

1 Answers1

0

You could read the form values via either jQuery or javascript, save them to variables, construct a message body and email the form contents.

See below for more information:

How to send an email from JavaScript

More information on Mandrill

After sending the email, redirect the page as you have done (correctly) in your code -- but without the setTimeout.

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111