I'm kind of new to using coding so I may be missing the obvious here. I'm looking to create something like the output here in this discussion: How can I add multiple inputs from an HTML UI to a Google Spreadsheet?. I used the same code format, but somehow the form is blank when I execute the code? Here is the code as modified:
addItem.gs
function openInputDialog() {
var html = HtmlService.createHtmlOutputFromFile('Index');
SpreadsheetApp.getUi()
.showModalDialog(html, 'Make Booking');
}
function itemAdd(form) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
sheet.appendRow([" ", form.name, form.room, form.guesthouse, form.checkin, form.checkout, form.department]);
return true;
}
The HTML form:
Index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<br>
<form>
Name:<br>
<input type="text" name="name">
<br>
Room:<br>
<input type="text" name="room">
<br>
GuestHouse:<br>
<input type="text" name="guesthouse">
<br>
In:<br>
<input type="date" name="checkin">
<br>
Out:<br>
<input type="date" name="checkout">
<br>
Department:<br>
<input type="text" name="department">
<br><br>
<input type="button" value="Submit"
onclick="google.script.run
.withSuccessHandler(google.script.host.close)
.itemAdd(this.parentNode)" />
</form>
</html>
When I run the function, the form only has the dialog "Make Booking", the rest of the form is blank. I've scoured the net for what I could be doing wrong, unsuccessfully of course.
Any help would be greatly appreciated.