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

234
Views
Google Script: ¿cómo agregar una función en value="" en HTML con una función JS?

Así que es mi primera publicación en StackOverflow, lo siento si digo algo raro:

Por lo tanto, me gustaría mostrar la fecha de la función Hoy () en mi entrada con la identificación "nombre_archivo" (por lo tanto, será como un valor predeterminado):

webAppBoot.html

 <!DOCTYPE html> <html> <head> <?!= include('WebAppBoot-css'); ?> </head> <body> <form> <div class="input-field col s6"> <input id="file_name" type="text" class="validate"> <label for="file_name">File name</label> </div> </form> <?!= include('WebAppBoot-js'); ?> </body> </html>

index.gs

 function doGet(request) { return HtmlService.createTemplateFromFile('WebAppBoot') .evaluate(); } function include(filename) { return HtmlService.createHtmlOutputFromFile(filename) .getContent(); }

Sé que puedo escribir totalmente la función Today() desde este archivo WebAppBoot-js.html

 <script> document.getElementById("file_name").value = google.script.run.Today(); </script>

Pero prefiero agregarlo desde este archivo: functions.gs

 function Today() { var today = new Date(); var dd = String(today.getDate()).padStart(2, '0'); var mm = String(today.getMonth() + 1).padStart(2, '0') var yyyy = today.getFullYear(); return mm + '/' + dd + '/' + yyyy; }

Entonces, como lo intenté, no funciona como puede ver: valor indefinido

Pero aún puedo ver que la función está funcionando con una Logger.log(Today()) Entonces, para resumir, en definitiva, me gustaría tener eso cuando abrimos el formulario: Resultado final

Me puedes ayudar ? Gracias

about 4 years ago · Santiago Trujillo
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!