There was an error that I don't know where it was wrong. I recently started writing code from YouTube. So I would like to have some advice on where I should fix it and make the code work.
**code**
function doGet() {
return HtmlService.createHtmlOutputFromFile("inded");
}
function userClicked(data){
var url ="myurl";
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName([data.shet]);
ws.appendRow([data.nb,data.kun,data.bath,data.tod,data.bon,data.lan,data.sam,data.ha]);
}
The only information(nb,kun,bath,tod,bon,lan,sam,ha) I will enter is numbers. The 'shet' is the number of the sheet.
**html**
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>กรอกเลข</h1>
<div>
<label>ใบที่</label><input type="text" id="shet">
</div>
<div>
<label>ตัวเลข</label><input type="text" id="nb">
</div>
<div>
<label>คูณ กลับ</label><input type="text" id="kun">
</div>
<div>
<label>เต็ง บาท </label><input type="text" id="bath">
</div>
<div>
<label>โต๊ด</label><input type="text" id="tod">
</div>
<div>
<label>วิ่งบน</label><input type="text" id="bon">
</div>
<div>
<label>วิ่งล่าง</label><input type="text" id="lan">
</div>
<div>
<label>2ใน3</label><input type="text" id="sam">
</div>
<div>
<label>2ใน5</label><input type="text" id="ha">
</div>
<div>
<button id="btn"> บันทึกข้อมูล </button>
</div>
<script>
document.getElementById("btn").addEventListener("click", saveData);
function saveData() {
var data = {}
data.shet = document.getElementById("shet").value;
data.nb = document.getElementById("nb").value;
data.kun = document.getElementById("kun").value;
data.bath = document.getElementById("bath").value;
data.tod = document.getElementById("tod").value;
data.bon = document.getElementById("bon").value;
data.lan = document.getElementById("lan").value;
data.sam = document.getElementById("sam").value;
data.ha = document.getElementById("ha").value;
google.script.run.userClicked(data);
document.getElementById("shet").value="";
document.getElementById("nb").value="";
document.getElementById("kun").value="";
document.getElementById("bath").value="";
document.getElementById("tod").value="";
document.getElementById("bon").value="";
document.getElementById("lan").value="";
document.getElementById("sam").value="";
document.getElementById("ha").value="";
}
</script>
</body>
</html>