Mahhdy
Mahhdy

Reputation: 592

Google Web App: Can't read or write on my label after evaluate the page

I have a label on my HTML page which shows number returned values. I can't read or change that when it is loaded? but locally I can do that with a console log.

<p name= 'message' id='ftext' > This team have 
  <label id="teams" > <?= teamSize ?> </label>
  members.  </p>

it returns null for both of these tag ids document.getElementById('team') or document.getElementById('ftext'), so I can't get their innerText or text Contents. I am using HtmlService.createTemplateFromFile(file).evaluate() for rendering the page.
here is a link to my project: Attendance Form

Thanks for your help,
M

Upvotes: 0

Views: 45

Answers (1)

J. G.
J. G.

Reputation: 1832

You said that document.getElementById('team') didn't work, but you actually named your id "teams".

If that fix doesn't work, can you share your code?

It's really frustrating to get variables between the frontend and the backend in GAS!

Something like this:

  google.script.run
  .withSuccessHandler(finishedOutput)
  .withFailureHandler(errorOutput)
  .split(); // SPLIT IS THE GS SCRIPT THAT PASSES BACK THE NUMBER YOU WANT

and then this

  function finishedOutput(info) //INFO IS THE THING THAT GOT PASSED BACK BEFORE
  {
    var br='<br />';
    var outputDiv = document.getElementById('status');
    outputDiv.innerHTML = 'The spreadsheet has been split.' + br +'New files in this folder: ' + info.link + br ;
    document.getElementById('process').style.display="none";

  };

In my example I was passing back an object that had a info key but you can do this with a number or a string rather than an object.

these are both inside on the html page, and then the "split" function is on Code.gs and is a GAS function. Messy, right?

Upvotes: 1

Related Questions