So it's my first post ever on StackOverflow, so sorry if I tell something weird:
So, I would like to display the date from the function Today() in my input with the id "file_name" (so, it will be like a default value):
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();
}
I know that I can totally write the function Today() from this file WebAppBoot-js.html
<script>
document.getElementById("file_name").value = google.script.run.Today();
</script>
But I prefer to add it from this file : 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;
}
So, as I tried, it's not working as you can see: undefined value
But I can still see that the function is working with a Logger.log(Today()) function
So, to resume, in definitive, I would like to have that when we open the form:Final result
Can you help me ? Thank you