Grant Grant - 1 year ago 65
HTML Question

Getting blank screen after running Google web app script

I am working on a check-in app though Google Sheets and want to make a search function that that takes a sport name as input in an HTML form and then returns information about the sport from the sheet in a HTML table. However, when I try to test the web app, nothing happens. How can I fix this?

Here is my code:


<!DOCTYPE html>
<?!= HtmlService.createHtmlOutputFromFile('Stylesheet').getContent(); ?>

<fieldset id="tasks-panel">

<form name="sport-form" id="sport-form">
<label for="sport-name">Search a sport by name:</label>
<input type="text" name="sport-name" id="sport-name" />
<button onclick='addTable()' id='submit-button'>Press this</button>

<p>List of things:</p>
<div id="toggle" style="display:none"></div>

<?!= HtmlService.createHtmlOutputFromFile('Javascript').getContent(); ?>



function addTable() {
var sportInput = $('sport-name').value();
var columnNames = ["Names", "Times"];
var dataArray =;

var myTable = document.createElement('table');

var y = document.createElement('tr');

for(var i = 0; i < columnNames.length; i++) {
var th = document.createElement('th'),
columns = document.createTextNode(columnNames[i]);

for(var i = 0 ; i < dataArray.length ; i++) {
var row= dataArray[i];
var y2 = document.createElement('tr');
for(var j = 0 ; j < row.length ; j++) {
var th2 = document.createElement('td');
var date2 = document.createTextNode(row[j]);

//Setting up global variables
var ss = SpreadsheetApp.openById("-spreadsheetID-");
var sheet = ss.getSheetByName("Sheet1");

var sportsFromSheet = sheet.getRange("D4:D12");
var namesFromSheet = sheet.getRange("B4:B12").getValues();
var timesFromSheet = sheet.getRange("A4:A12").getValues();
var NAMES = [];
var TIMES = [];
var OUTPUT = [];

//doGet function
function doGet() {
return HtmlService.createTemplateFromFile('Index').evaluate()
.setTitle('Check In Data')

//Gets both names and times of checked-in people
function getSportData(input) {
var sportInput = input;


return OUTPUT;

//Puts the names of every person from an inputted sport into an array.
function getNamesInSport(input) {
var data = sportsFromSheet.getValues();

for (var i = 0; i < data.length; i++) {
if(data[i] == input){

//Puts the times of every person from an inputted sport into an array.
function getTimesInSport(input){
var data = sportsFromSheet.getValues();

for (var i = 0; i < data.length; i ++) {
if(data[i] == input){

Answer Source

JQuery id selectors must be prefixed with # so to grab the value from the the 'sport-name' input you'll need to select it using

var sportInput = $('#sport-name').val();

Additionally, as Robin comments above, if you want to use the JQuery library you'll need to load it, the code you've shown indicates you might not have done this?

<script src=""></script>

Although if this were the case you'd probably be seeing a '$ is not defined' error straight away.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download