In google apps script using HTML Service how to create a custom web page interface to capture basic user information and load data to a MySQL database. I am doing this in a google sheet using the below code
function getHtml() {
var ss = SpreadsheetApp.getActiveSpreadsheet(),
html = HtmlService.createHtmlOutputFromFile('index');
ss.show(html);
}
function getData(form){
var firstName = form.firstName,
lastName = form.lastName,
dob = form.dob,
email = form.email,
phone = form.phone,
sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.appendRow([firstName, lastName, dob, email, phone]);
}
//index.html
<!DOCTYPE html>
<html>
<b>Add Record</b><br />
<form>
First name: <input id="firstname" name="firstName" type="text" /> <br />
Last name: <input id="lastname" name="lastName" type="text" /> <br />
DOB: <input id="dob" name="dob" type="date" /> <br />
Email: <input id="email" name="email type="text" /> <br />
Phone: <input id="phone" name="phone" type="text" /> <br />
<input onclick="formSubmit()" type="button" value="Add Record" /> <br />
<input onclick="google.script.host.close()" type="button" value="Exit" />
</form>
<script type="text/javascript">
function formSubmit() {
google.script.run.getValuesFromForm(document.forms[0]);
}
</script>
</html>