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

90
Views
Google Script SQL with HTML

My issue is, I'm using the yiono SCRIPT sql library and trying to integrate it with HTML but am having trouble with 2 pieces. Everything else is working beautifully.

For example I want to make an HTML form to update the 'Pro' value on the row that 'ID' = '1'

It works beautifully when I run the function in IDE, but I don't know the best way to put these in as variables from an HTML page. I tried some silliness with GET requests but couldn't get it to work.

function update_row(){
  var SQL = new gSQL();
  SQL.DB('*redacted*').TABLE('DAILY-DATA').UPDATE('Pro').WHERE('ID', '=', '1').VALUES('KAOS').setVal();
}

Problem 1: Get form input into .WHERE('ID', '=','from_html_form') and I'd like to do it within the Google environment by way of web app.

Minimal Reproducible Example

Here is the function

Here is the result

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Replace

function update_row(){
  var SQL = new gSQL();
  SQL.DB('*redacted*').TABLE('DAILY-DATA').UPDATE('Pro').WHERE('ID', '=', '1').VALUES('KAOS').setVal();
}

by

function update_row(input = '1'){
  var SQL = new gSQL();
  SQL.DB('*redacted*')
    .TABLE('DAILY-DATA')
    .UPDATE('Pro')
    .WHERE('ID', '=', input)
    .VALUES('KAOS')
    .setVal();
}

Main changes

  1. added a parameter with a default value
  2. Replaced a literal by the parameter NOTES: The breaklines are not really required, it's a matter of programming style.

Add the below simple trigger to a .gs file in your Google Apps Script project.

function doGet(e){
  const html = `
    <input type="number" />
    <button onClick="myFunction();">Submit</button>
    <script>
      function myFunction(){
        google.script.run
          .withSuccessHandler(()=> {
            const div = document.createElement('div');
            div.innerText = 'Done!'
            document
             .body
             .appendChild(div)
           }) 
    .update_row(document.querySelector('input').value);
   }
   </script>`
return HtmlService.createHtmlOutput(html);
}  

To test this you will have to deploy as web app. Please follow the instructions for this on https://developers.google.com/apps-script/guides/web.

Resources

  • https://developers.google.com/apps-script/guides/web
  • https://developers.google.com/apps-script/guides/html/communication?hl=en#forms
about 4 years ago · Santiago Trujillo 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!