I have a simple html form with email sending
this is the html file:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function submitForm() {
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var comment = document.getElementById('comment').value;
/**
* First run submitData(name, email, comment) function of Code.gs
* Then, run showMessage(value) function of this html file
*/
google.script.run
.withSuccessHandler(showMessage) // execute showMessage(value) function on success
.submitData(name, email, comment); // call submitData(name, email, comment) function present in Code.gs file
}
function showMessage(value) {
document.getElementById('message').innerHTML = value;
document.getElementById('name').value = '';
document.getElementById('email').value = '';
document.getElementById('comment').value = '';
}
</script>
</head>
<body>
<h2>Feedback Form</h2>
<div id="message" style="color:green"></div>
<p><input id="name" type="text" placeholder="Your Name"><p>
<p><input id="email" type="email" placeholder="Your Email"></p>
<p><textarea id="comment" rows="10" cols="40"></textarea></p>
<p><button onclick="submitForm(); return false;">Submit</button></p>
</body>
</html>
and this is the gs file:
function doGet(e) {
return HtmlService
.createHtmlOutputFromFile('index.html')
.setTitle("Simple HTML Form Example");
}
function submitData(name, email, comment) {
var subject = 'New Feedback';
var body = 'Name: ' + name + '<br> Email: ' + email + '<br> Comment: ' + comment;
var to = '[email protected]'; // EMAIL ADDRESS WHERE THE FEEDBACK EMAIL IS SENT
MailApp.sendEmail({
to: to,
subject: subject,
htmlBody: body
});
return 'Feedback Sent!';
}
I'm looking for a formula to view the edited fields name, email, instead of the text "Feedback Sent!"
Thanks in advance for the help!