Created
October 28, 2020 14:33
-
-
Save apivat60/e9b9ce9c75b6a5308765061d4a1e73df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////// 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