In GAS, select Publish the script below → Install as web application and jump to the provided url.The following error will appear in the browser window.
What should I do? Thank you.

The following sites were used as reference for creating the source code.
・ First step to create a web application with Google Apps Script
・ Give the script results to a web page created with Google Apps Script Output and display
・ Give spreadsheet values ​​to web applications with Google Apps Script Output

// code.gs
function doGet () {
  return HtmlService.createTemplateFromFile ("hello"). evaluate ();
<! DOCTYPE html>
    <base target = "_ top">
        var repeat = 1;
        var myData = SpreadsheetApp.getActiveSheet ();
        Logger.log ('hello');
        function answerButtonClick (click_value) {
          output.append ('answerButtonClick is called');
          for (var j = 1;j<= 4;++ j) {// loop with alternatives
            if (click_value == "Button" + j) {// If the loop choice matches the user choice
              if (myData.getRange ("F" + (repeat + 1)). getValues ​​() == click_value) {
                output.append ('correct answer');
              } else {
                output.append ('Incorrect');
              ++ repeat;
          } // for
        } // function
        do {
          output.append ('<p>' + "Problem" + repeat + "</P>");// Display the problem number
          output.append ('<li>' + myData.getRange ("A" + (repeat + 1)). getValues ​​() + '</li>');// get the problem statement
        } while ();
    <input type = "button" value = "1" onclick = "answerButtonClick (this.value)">
    <input type = "button" value = "2" onclick = "answerButtonClick (this.value)">
    <input type = "button" value = "3" onclick = "answerButtonClick (this.value)">
    <input type = "button" value = "4" onclick = "answerButtonClick (this.value)">
SyntaxError: Syntax error. (Line 2, file "code", project "test")

Addition ①

Thanks for your response.
When you go home with the browser showing gas on the university computer and open the same project on your home computer, the error "Server error occurred. Please press [Reload] in the browser." Even if it is displayed, I will give up on the correction at home. Tomorrow at noon, I would like to make corrections and present the results.

Addition ②

For the time being, when the gs file was modified as follows, the following error occurred, so if you added the indication that "no syntax error is found in the gs file", a syntax error occurred in the html file.

function doGet () {
  var template = HtmlService.createTemplateFromFile ("hello");
  return template.evaluate ();
SyntaxError: Syntax error. (Line 3, file "code")

After that, I would like to work on correcting the html file.

Addition ②

For the time being, a syntax error occurred in gs, but this post is closed because it turns out that it is actually a syntax error in the html file.
Thank you very much for your response.

  • Answer # 1

    hello.html is strange.

    SpreadsheetApp.getActiveSheet ()does not work properly from scripts that are not associated with


    ↓ This is an error.
    var myData = SpreadsheetApp.getActiveSheet ();

    is executed on the server side. Therefore, theanswerButtonClickfunction cannot be executed on the client side.
    If you want to run it on the client side, add a