Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created July 8, 2020 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rheajt/db0278e66908909f850619716d02f22a to your computer and use it in GitHub Desktop.
Save rheajt/db0278e66908909f850619716d02f22a to your computer and use it in GitHub Desktop.
function doGet() {
var html = HtmlService
.createHtmlOutputFromFile('form')
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
return html;
}
function submit(name) {
SpreadsheetApp.getActive()
.getActiveSheet()
.appendRow([name, new Date()]);
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<div id="demo">
<input id="name" type="text" placeholder="Input your name here..." />
<button id="btn" type="button">Submit</button>
</div>
<script>
function submit(e) {
var name = document.getElementById('name').value;
google.script.run.submit(name);
}
document
.getElementById('btn')
.addEventListener('click', submit);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment