I’ve been trying to figure out how to submit form data without using PHP code, is there a way? The mailto:
in HTML 5 only has the user fill the form out, then when submit
is clicked, it opens another application (mail app on desktop/laptop, and mail app on smartphones) and puts the data fields inside the message and makes the user click send in their mail, what do I do to at least just make the email sent to my email without the user having to take extra steps? Or being redirected to another app?
Advertisement
Answer
If I understand correctly, I think you can do the following. Grab the values of the inputs through javascript and send the email using window.location
with the input values.
HTML
<input type="text" id="subject"> <textarea id="body"></textarea> <button type="button" id="send">Submit</button>
JS
$('#send').on('click', function(e) { e.preventDefault(); subject = $('#subject').val(); body = $('#body').val(); window.location = "mailto:test@example.com?subject=" + subject + "&body=" + body; });