S
S
Stolen19932021-03-09 21:29:29
Google Apps Script
Stolen1993, 2021-03-09 21:29:29

How to move variable from body script html to code.gs?

There is a web application in google apps script. We need to move the img variable from html to the dopost function. The value of the variable is set for the test, then I will change it.
HTML:

<script>
html2canvas(document.querySelector(".wrap")).then(function(canvas) {
    var img = "5";
    });
    </script>


Code.gs:
function doGet(e) {
  var htmlTemplate = HtmlService.createTemplateFromFile('index');  
  return htmlTemplate.evaluate();  
  
}  

function glide(e) {  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var ds = ss.getSheetByName('Заказ-наряд');
  var range = ds.getRange("A1:DF2").getValues();
  return range;
}

function doPost() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var ds = ss.getSheetByName('Заказ-наряд');
    ds.getRange(3,3).setValue(img);
    return ds.getRange(3,3).setValue(img);
    
    console.log(img)
    
    }

function stuff(e) {
  doGet();
  doPost();
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question