I'm trying to build a user interface in html service available directly in a spreadsheet.
It's quite easy to display and to close a dialog box following the google tutorial.
But this exemple only show how to close the dialogbox, there is nothing to interact with the google script.
What I want to do is to build a little form and at the end the button submit should return a value to the script so it can follow the process.
Using something like: google.script.run.withSuccessHandler(showConfirmation).processData("data") open a new windows that say there is nothing there. and the script don't process the data (I got an error:"Cannot read property 'processData_m___' of undefined" ).
So, my question is, does that's something doable?
In the sample given by google I saw they changed the "google.script.run" for "google.script.host" I tried to do something with that but it revealed to be unsuccessfull.
here my sample code:
Script code:
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [{name: "show dialog", functionName: "showDialog"}];
ss.addMenu("script center menu", menuEntries);
}
function showDialog(){
var htmlTemplate = HtmlService.createTemplateFromFile("index");
var html = htmlTemplate.evaluate();
try{
return(SpreadsheetApp.getUi().showDialog(html));
}
catch(err){
return(SpreadsheetApp.getActive().show(html));
}
}
function processData(e){
Logger.log(e);
Logger.log(JSON.stringify(e));
}
Html code:
<div>
<div>please type something</div>
<form>
<input type="text" id="text">
<input type="submit" value="submit" onClick="showConfirmation();google.script.host.run.processData(document.getElementById('text').value);">
</form>
</div>
<script>
function showConfirmation(){
console.log(document.getElementById("text").value);
google.script.host.run.processCsv(document.getElementById("text").value);
google.script.host.close();
}
</script>
Thank's in advance for your help.
Harold