Kali ini kita akan mencoba membuat contoh form pengiriman pesan ke Google Spreadsheet melalui Google Script.
KODE FORM :
<form action="https://script.google.com/macros/s/AKfycbz..................rQjozIQ/exec?callback=ctrlq">//ulr aplikasi google script
Id: <input type="text" name="ID" value="12345"><br>
User: <input type="text" name="USER" value="Jhon"><br>
<input type="hidden" name="action" value="insert">
<input type="submit" value="Submit">
</form>
GOOGLE SCRIPT :
function doGet(e){
var op = e.parameter.action;
var ss=SpreadsheetApp.openById("SPREADSHEET_ID");
var sheet = ss.getSheetByName("SHEET_NAME");
if(op=="insert")
return insert_value(e,sheet);
}
function insert_value(request,sheet){
var user = request.parameter.USER;
var id = request.parameter.ID;
var flag=1;
if(flag==1){
var rowData = sheet.appendRow([id,user]);
var result="Insertion successful";
}
result = JSON.stringify({
"result": result
});
return ContentService
.createTextOutput(request.parameter.callback + "(" + result + ")")
.setMimeType(ContentService.MimeType.JAVASCRIPT);
}
Sekian dulu selamat berkreasi.
ConversionConversion EmoticonEmoticon