OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

web app google script can not access html element with javascript function

  • Thread starter Thread starter RonJohnx11
  • Start date Start date
R

RonJohnx11

Guest
I have a simple html file with labels and text fields with ids (like firstname id=“fn”, lastname id=“ln”, and address id=“add”). So far my web app runs fine with inline Javascript that gets the value of these elements and stores them in a google sheet. So far “nothing” I try will let me getElementById with the google script. It’s the “exact” same code but one runs inline with the html file and the other one run in an html file in the web app as google script.

I have tried every way possible to getElementById in my google script and it I always get the same answer which is “TypeError: Cannot read properties of undefined (reading 'firstName')”. This is the simple code: var userInfo = {}; userInfo.firstName = document.getElementById("fn").value;

This code is to be executed when the user types in his name and address and then clicks the button when done.

<p>I have a simple html file with labels and text fields with ids (like firstname id=“fn”, lastname id=“ln”, and address id=“add”). So far my web app runs fine with inline Javascript that gets the value of these elements and stores them in a google sheet. So far “nothing” I try will let me getElementById with the google script. It’s the “exact” same code but one runs inline with the html file and the other one run in an html file in the web app as google script.</p>
<p>I have tried every way possible to getElementById in my google script and it I always get the same answer which is “TypeError: Cannot read properties of undefined (reading 'firstName')”. This is the simple code:
var userInfo = {};
userInfo.firstName = document.getElementById("fn").value;</p>
<p>This code is to be executed when the user types in his name and address and then clicks the button when done.</p>
 

Latest posts

Top