I would like to create a HTML File / JS File within Google Apps Script that allows the user to input some data and then the data should be processed.
I created already a basic HTML Interface however I dont quite get how I make this data usable on submit in the further Google Script. Can someone explain how to continue from here?
function doGet(htmlfile, title) {
var html = HtmlService.createHtmlOutputFromFile(htmlfile);
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showModalDialog(html, title);
}
function run_html_interface(){
doGet("Interface","Adding item to a themepage category");
}
function success_input(form_output){
SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/12WYgdCpaczfmrEI_o-s75ae9Zf8fB4AURZScScPdTvw/edit#gid=0").getSheetByName("Input").getRange("D5").setValue("Hello")
Logger.log(form_output)
var category = form_output.cat3;
Logger.log(category)
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script async>
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(google.script.host.close()).success_input(formObject);
}
</script>
</head>
<body>
<form id="myForm" onsubmit="event.preventDefault(); handleFormSubmit(this)">
<div>
<label for="cat3">Category Name</label>
<input type="text" placeholder="Category Name (e.g. Nie wieder schleppen)" value="" id="cat3">
</div>
<div>
<label for="articleid">Article ID</label>
<input type="text" placeholder="Article ID" value="" id="articleid">
</div>
<div>
<label for="position">Position to set the Article ID</label>
<input type="text" placeholder="Position Number (e.g. 1,2,3,..)" value="" id="position">
</div>
<input class="btn btn-light" type="submit" value="Submit" />
</form>
</body>
</html>