Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

572
Views
How to Show Table from google speadsheet after login (Google Web App)

Everybody . I'm doing some mini web-app but I'm new in programming ,I followed tutorial from "Learn Google Spreadsheets" on Youtube but get a little bit confuse

My App is very simple 1.User login Page (Check Usercode and Pass from firebase) --- DONE! 2.Get data (get Usercode and find data row from spreadsheet) --- DONE! 3.Pass Object to Table --- Need help

    var ss= SpreadsheetApp.openById('1l2Q7C5qBF7EsDInlHi1Bv76jeRJwWjixKteBkc8i3ik');
var PayrollSheet = ss.getSheetByName("ข้อมูลล่าสุด") ;
var Route = {} ;
Route.path = function(route,callback){
  Route[route] = callback ;
}

function doGet(e) {

  Route.path("Login",LoadLogin) ;
  Route.path("Table",LoadTable) ;

  if(Route[e.parameters.v]){
      return Route[e.parameters.v]() ;

  }else {
      return render("Login") ;
 }

}

function LoadLogin(){

  return  HtmlService.createTemplateFromFile('Login').evaluate() ;

}

function LoadTable(Usercode){

var TargetRow = GetRow(Usercode) ;
var Data  =    PayrollSheet.getRange(TargetRow,1,1,18).getValues().flat();
var Round =   PayrollSheet.getRange(1,2,1,2).getValues().flat();


return render("Table",{array:Data,round:Round}) ;

}

function render(file,argsObject){

var tmp = HtmlService.createTemplateFromFile(file);
if(argsObject){
  var keys = Object.keys(argsObject) ;

      keys.forEach(function(key){
  
          tmp[key]   = argsObject[key] ;

        });

      } // END IF
   return    tmp.evaluate() ;
}

Javascript in html file

    <script>

function LoginUser() {
   
    var usercodeIn = document.getElementById("Usercode").value;
    var passwordIn = document.getElementById("Password").value;

    google.script.run.withSuccessHandler(function(User){ 
    
      if(User != 'FALSE')  // Found User
      {
       document.getElementById("errorMessage").innerHTML = "welcome " + User ;

       google.script.run.LoadTable(usercodeIn) ;

      }
      else if(User == 'FALSE') //Not Found User
      {
        document.getElementById("errorMessage").innerHTML = "Wrong Password!";     
      }    
    }).checkLogin(usercodeIn,passwordIn);

    }

</script>

After Login successful I try to run Loadtable(usercode) to render Table.html with data base on usercode but It only login and show success prompt , but not render Table.html

This is sound pretty easy, but I really don't know what to do ,So please help Thank you

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Provided there are no Date objects in argsObject you could simply do tmp.argsObject = argsObject.

Code.gs

function render(file,argsObject){

  var tmp = HtmlService.createTemplateFromFile(file);
  if(argsObject){
    tmp.argsObject = argsObject.
  } 
  return    tmp.evaluate() ;
}

Then in your templeted HTML.

<table>
  <? for (let i = 0; i < argsObject.array.length; i++) { ?>
    <tr><td><?= argsObject.array[i] ?></td></tr>
  <? } ?>
</table>

Reference

  • Templated HTML
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!