Get input text from HTML to .GS

76 views
Skip to first unread message

Stefano

unread,
Dec 26, 2023, 1:30:44 PM12/26/23
to Google Apps Script Community
Hi! I don't understand how to get input text from html form, to pass at .gs file.
I would like rename a sheet (Spreadsheet), from HTML form by input text.

I have tried this:
HTML file:
 <input type="text" id="fname" name="fname"><br><br>
<button onclick="google.script.run.nuovocontatore('fname')">Nuovo contatore</button>

.GS file
function nuovocontatore(test){
SpreadsheetApp.getActiveSpreadsheet().insertSheet(test)
}

I know is not perfect, so I've tried different ways....but...not run.
I'm doing it as an excercise but I mistake something.
Thanks.

Stefano

Tanaike

unread,
Dec 26, 2023, 8:42:35 PM12/26/23
to Google Apps Script Community
If you want to use your showing function "nuovocontatore", how about modifying your HTML as follows?

<input type="text" id="fname" name="fname"><br><br>
<button onclick="google.script.run.nuovocontatore(document.getElementById('fname').value)">Nuovo contatore</button>

By this modification, when you input text to the input tag and click a button, a new sheet with the inputted text is inserted into the active Spreadsheet.

Stefano

unread,
Dec 27, 2023, 7:14:20 AM12/27/23
to Google Apps Script Community
Perfect thanks!
Reply all
Reply to author
Forward
0 new messages