Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

406
Visualizações
¿Cómo puedo usar la variable en el archivo gs como valor de entrada en el archivo HTML en el script de Google Apps?

La variable fieldName para la función testGetFieldName se encuentra en Code.gs

Quiero insertarlo en el valor de entrada del archivo index.html.

Pero si abro Sidebar usando testSetValue, el valor aparece como no definido.

¿Cómo puedo hacer que la variable 'Cuenta' salga con Valor?

El código que escribí es el siguiente.

 //code.gs function testGetFieldName(){ var fieldName = 'Account'; return fieldName; } function testSetValue(){ var html = HtmlService.createTemplateFromFile('index'); var output = html.evaluate() .setTitle('MySidebar') .setWidth(400) .setSandboxMode(HtmlService.SandboxMode.IFRAME); SpreadsheetApp.getUi().showSidebar(output); }

índice.html

 <!DOCTYPE html> <html> <head> <base target="_top"> </head> <body> <input type="text" id ='textValue' name='textValue' value=''/> <script> document.getElementById('textValue').setAttribute('value',google.script.run.testGetFieldName()); </script> </body> </html>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

En su guión, ¿qué tal la siguiente modificación?

Lado de Google Apps Script:

De:

 var html = HtmlService.createTemplateFromFile('index'); var output = html.evaluate()

A:

 var html = HtmlService.createTemplateFromFile('index'); html.value = testGetFieldName(); var output = html.evaluate()

Lado HTML:

De:

 document.getElementById('textValue').setAttribute('value',google.script.run.testGetFieldName());

A:

 document.getElementById('textValue').setAttribute('value', '<?= value ?>');

Nota:

  • Si desea utilizar google.script.run , ¿qué tal la siguiente modificación?

    • De

       document.getElementById('textValue').setAttribute('value',google.script.run.testGetFieldName());
    • A

       google.script.run.withSuccessHandler(e => { document.getElementById('textValue').setAttribute('value', e); }).testGetFieldName();

Referencia:

  • Servicio HTML: HTML con plantilla
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda