此图片来自我想获取访问者反馈的模态的引导模态我已经用HTML托管了此投资组合,我需要在没有使用Google Sheet的任何数据库的情况下获得反馈。
样本:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form id="test-form">
<div>
<label>Field 1</label>
<input type="text" name="field_1" placeholder="Field 1" />
</div>
<div>
<label>Field 2</label>
<input type="text" name="field_2" placeholder="Field 2" />
</div>
<button type="submit" id="submit-form" onclick="myJSFunction()">Submit</button>
</div>
</form>
<script>
function myJSFunction(){
var data=[];
data.push(document.getElementsByName("field_1")[0].value);
data.push(document.getElementsByName("field_2")[0].value);
google.script.run.handleResponse(data);
}
</script>
</body>
</html>
。gs文件
function doGet(e){ return HtmlService.createHtmlOutputFromFile('index'); } function handleResponse(data) { var sheet = SpreadsheetApp.openById('YOUR SPREADSHEET ID').getSheetByName(SHEETNAME); sheet.getRange('A1').setValue(data[0]); sheet.getRange('B1').setValue(data[1]); }