Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda