Retrieving information from the logger to provide back to the web application

I'm almost there, but not quite. The logger is showing the search results, but I still can't get them to display on the web app.

The search function works on the web app and the results show up in the logger.

Any advice would be appreciated. Thanks!

Here is the updated code:

function SearchFiles(searchTerm) {
var searchFor ="title contains '" + searchTerm + "'";
var owneris ="and '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c59717d75705c7971">[email protected]</a>' in Owners";
 var names =[];
var fileIds=[];
Logger.log(searchFor + " " + owneris);
var files = DriveApp.searchFiles(searchFor + " " + owneris);
while (files.hasNext()) {
  var file = files.next();
  var fileId = file.getId();// To get FileId of the file
  fileIds.push(fileId);
  var name = file.getName();
  names.push(name);
}

for (var i=0;i<names.length;i++){
  //this is showing in the Logger
Logger.log(names[i]);
Logger.log("https://drive.google.com/uc?export=download&id=" + fileIds[i]);
}

}

function returnNames() {
  var names = SearchFiles();
   return '<b>returnNames has ran.!</b> <br>' + names ;

}

function doGet(e) {
  var template = HtmlService.createTemplateFromFile('Index');
  return template.evaluate()
      .setTitle('Hello World')
   //   .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}


function processForm(searchTerm) {
  var resultToReturn;
  Logger.log('processForm was called! ' + searchTerm);
  resultToReturn  = SearchFiles(searchTerm);
  Logger.log('resultToReturn: ' + resultToReturn)
  // shows as undefined in the logger
  return resultToReturn;
}

function helloWorld()
{
  return "Hello World!";
}

INDEX:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <script>
      function displayMessage() {
        var searchTerm;
        searchTerm = document.getElementById('idSrchTerm').value;

        console.log('searchTerm: ' + searchTerm );
        
         google.script.run.processForm(searchTerm);
         google.script.run.withSuccessHandler(handleResults).returnNames();
       }
         
        
      function handleResults(returnVal){

         console.log('Handle Results was called! ');
         document.writeln(returnVal);
       }


    </script>
  </head>
  <body>
    <input type="text" id="idSrchTerm" name="search">   
    <input type="button" value="submitButton" name="submitButton" onclick="displayMessage()"/>

  </body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Prevent alert box from closing automatically without clicking the ok button in ASP.NET

I'm creating a project in ASP.NET where I need to display an alert box and then redirect to another page. Below is my code: var s = Convert.ToInt32(Session["id"].ToString()); var q = (from p in db.students where p.userid == s ...

Optimal approach to displaying views with Express.js and EJS

Recently, I came across a website that only renders EJS templates using Express.js routing. All the routes are defined in the /routes/index.js file. As the file grows with more routes being added, I am thinking about restructuring it to make it more develo ...

Best practices for sending an object from client to server using Node.js

What is the best way to transfer a large object from client side to my node.js server? The object is currently stored in a variable within my script tags. ...

Adjust the div's height to 0

I need to dynamically set the height of a div element with a height of 34px to 0px. However, this div does not have a specific class or ID, so I can't use traditional DOM manipulation methods like .getElementById(), .getElementByClassName, or .getElem ...

Storing toggle open state using a variable

I have created a toggle open/close DIV with a UL list inside that looks like this: <div id="dropdown-1"> <div class="option-heading"> <i class="fa fa-angle-double-up"></i> <i class ...

What steps can be taken to adjust a module required in Node.js prior to initiating the build process?

Module A.js (standard NPM package): module.exports = { ... const wsUrl = `ws://${customHostname}:${customPort}/sockjs-node/websocket`; ... }; Module B.js: const a = require('A'); Is there a way to substitute ${customHostname} & ${cu ...

Leveraging JavaScript code repeatedly

Apologies if this question has been asked before, as I couldn't find it. I have an HTML table with images used as buttons: <td> <button class="trigger"> <img src="D:\Elly Research\ CO2858\Presentation\Calypso ...

Customize Your Google Maps with Checkboxes for Style Options

Trying to make dynamic changes in the style of a Google Maps using checkboxes. Some checkboxes control colors of features, while others control visibility. Having trouble figuring out how to combine different features of styles since they are not strings ...

Transform the JavaScript function to a Node.js module

My function serves as an abstract factory for creating JavaScript objects. Here is the code: var $class = function(definition) { var constructor = definition.constructor; var parent = definition.Extends; if (parent) { var F = function ...

Function modifies global variable

What could be causing the global variable to change when using the function write_ACK_ONLY()? I'm passing the array rxUartBuffer to write_ACK_ONLY() as data = new Array(20), but upon checking the Log Output, it seems that the function is also modifyin ...

Is the drag-and-drop feature not working properly?

I'm new to coding in Javascript and I'm attempting to insert an image inside a border created with CSS. Unfortunately, the script doesn't seem to be working properly. It's possible that there is a small error in the code causing the iss ...

"Utilizing NodeJS in conjunction with socket.io and PostgreSQL's LISTEN feature

My goal is to create a frontend that can detect events whenever a specific table in my Postgres database is modified. The Postgres events are triggering correctly and I am able to transmit them through the Socket.io connection. However, I am experiencing ...

Using React hooks to reset state in a reducer: step-by-step guide

event.js import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Link, useHistory } from 'react-router-dom'; import { addEvent } from '../actions/event'; ...

A JQuery function linked to the click event of the body element triggers another click event right away

$().ready(function(){ $("#move-to").click(function(){ $("body").bind("click",function(){ alert("foo"); }); }); }); Why do I receive an alert message of "foo" immediately after clicking on "move-to"? When I bind the " ...

Extracting Data from Multiple Pages Using Python 3 without Changing URL

Recently, I delved into the world of web scraping and decided to try my hand at grabbing data from various websites. Currently, I'm focused on scraping information from the site - Using selenium, I've managed to extract longitude and latitude da ...

Deliver varied asset routes depending on express js

I have a situation where I am working with express routes for different brands. My goal is to serve two separate asset directories for each brand route. One directory will be common for all brand routes, located at public/static, and the other will be spec ...

Only a fragment of the .attr() method

I am trying to work with an image HTML block <img src="folder1/folder2/folder3/logo1.png"> situated inside a large div similar to this structure <div id="editorial"> <div id="img_editorial"><img src="folder1/folder2/folder3/logo1. ...

Having issues with npm python-shell integration within electron framework

I'm currently attempting to establish a connection between a python script and an Electron app by utilizing the npm's python-shell package. The requirement is for the script to be executed whenever a button is clicked. So, let's assume my d ...

Can I send a DELETE request with request body and headers using Axios?

When working with Axios in ReactJS, I am attempting to send a DELETE request to my server. In order to do this, I need to include the following headers: headers: { 'Authorization': ... } The body of the request consists of: var payload = { ...

What's the best way to animate the navigation on top of an image for movement?

I am currently in the process of creating my website as a graphic designer. My unique touch is having the navigation positioned on top of an image (which is animated via flash). This setup is featured prominently on my homepage, which is designed with mini ...