Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apivat60/e9b9ce9c75b6a5308765061d4a1e73df to your computer and use it in GitHub Desktop.
Save apivat60/e9b9ce9c75b6a5308765061d4a1e73df to your computer and use it in GitHub Desktop.
////// app script
function doGet(e) {
return HtmlService.createHtmlOutputFromFile("index");
}
function saveData(name,phone){
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.appendRow([new Date(),name,"'"+phone]);
}
/////////html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>ระบบบันทึกข้อมูลด้วย Web App</h1>
<label>ชื่อ สกุล:</label><input type="text" id="username">
<label>เบอร์โทร:</label><input type="text" id="tel"><p>
<button id = "btn">บันทึกข้อมูล</button>
<script>
document.getElementById("btn").addEventListener("click",submit);
function submit(){
var name = document.getElementById("username").value;
var phone = document.getElementById("tel").value;
google.script.run.saveData(name,phone);
document.getElementById("username").value="";
document.getElementById("tel").value="";
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment