logo
down
shadow

webapp form value to spreadsheet


webapp form value to spreadsheet

By : Lilet Yape
Date : November 21 2020, 03:00 PM
I wish this helpful for you How about a following modification?
Modification points : For Index.html, is missing. About form.a+j, you can retrieve the values using form["a" + j]. ndata is JSON like {a1: "value", a2: "value"}. So when ndata is imported to cells, it becomes undefined. When several values are imported to cells, the importing efficiency becomes higher by using setValues().
code :
function doGet(e) {
  return HtmlService
  .createTemplateFromFile('Index')
  .evaluate()
  .setSandboxMode(HtmlService.SandboxMode.NATIVE)
}

function writeForm(form) {
  var ss = SpreadsheetApp.openById('1bKrGjBV*****');
  var sheet = ss.getSheets()[0];
  var data = ss.getDataRange().getValues();
  var input = []; // Modified
  // var ndata = form
  for(var j=0;j<data.length;j++){
    var value = form["a" + j]; // Modified
    input.push([value]) // Modified
  }
  sheet.getRange(1, 4, input.length, input[0].length).setValues(input); // Added
  // for(var k=0;k<data.length;k++) {
  //   sheet.getRange(k+1,4).setValue(ndata[k]);
  // }
  // var range = sheet.getRange(1, 5);
}

function getData(){
  return SpreadsheetApp
   .openById('1bKrGjBV*****')
   .getSheets()[0]
   .getDataRange()
   .getValues();
}
<body>
  <center><h1>Produce Inventory Form </h1></center>
  <style>
    table,th,td{border:1px solid black;}
  </style>
  <? var data = getData(); ?>
  <form id="invform">
    <input type = "submit" value="Submit" onclick="google.script.run.writeForm(this.parentNode)">
    <table align="center">
      <tr><th>Code</th><th>Name</th><th>ChName</th><th>On Hand</th></tr>
      <? for(var i=0;i<data.length;i++){ ?>
      <tr>
        <th><?= data[i][0] ?></th>
        <th><?= data[i][1] ?></th>
        <th><?= data[i][2] ?></th>
        <th><input type = "text" style="width:40px" min="0" maxlength="3" name=a<?= i ?>>
      </tr>
      <? } ?>
    </table>
  </form> <!-- Added -->
</body>


Share : facebook icon twitter icon
Google Spreadsheet Form, populate form options based on a spreadsheet

Google Spreadsheet Form, populate form options based on a spreadsheet


By : jaisimha
Date : March 29 2020, 07:55 AM
seems to work fine The functionality you are requesting doesn't currently exist. A feature request around linking Google's forms to spreadsheets would be your best bet to keep the two in sync.
There is always the option to create a form using URL parameters as outlined here: https://docs.google.com/support/bin/answer.py?hl=en&answer=160000
Simple google apps workflow Form->Spreadsheet->email Manager->Update spreadsheet & Requestor

Simple google apps workflow Form->Spreadsheet->email Manager->Update spreadsheet & Requestor


By : freeman
Date : March 29 2020, 07:55 AM
wish of those help The URL in action="xxxx" should be the one provided in the Publish dialog. It will end with /exec. You need to publish your script as a webapp, which will give you a URL, and ensure that your doPost() method is invoked there.
Writing JUnit Test on a webapp that is calling another webapp without running the second webapp

Writing JUnit Test on a webapp that is calling another webapp without running the second webapp


By : Jeff
Date : March 29 2020, 07:55 AM
To fix the issue you can do You can mock the second web application. E.g. you can use http://mock-server.com
Null value returned to Apps Script webapp for a certain spreadsheet by server function

Null value returned to Apps Script webapp for a certain spreadsheet by server function


By : Dan
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have ever experienced the same issue before. When the values with the date format are included in data which is retrieved by getSheetValues(), the returned values become null. I thought that the issue might occur when the date values are parsed and/or converted, when the values are sent from GAS to Javascript. By this, null is returned. In order to avoid this, I think that there are 2 patterns for your situation. Please chose one of them for your situation.
Pattern 1
code :
return data;
return JSON.stringify(data);
var data = sheet.getSheetValues(1, 1, maxRows, 10);
var data = sheet.getRange(1, 1, maxRows, 10).getDisplayValues();
Contents of a spreadsheet are not displayed in the deployed Apps Script webapp

Contents of a spreadsheet are not displayed in the deployed Apps Script webapp


By : Joepolaskx
Date : March 29 2020, 07:55 AM
should help you out EDIT as @tehhowch pointed out his answer is the correct solution here.
For your case you should make these changes, getData():
code :
function getData(){
  var sheet = SpreadsheetApp.openById("1k_kj98U__0Bk44gh0qRFpaVx0ru3sN1pSPGiMQwimxo").getSheets()[0];
  return JSON.stringify(sheet.getDataRange().getValues()); // return value as Json
}
function showData(data) {
      var arr = JSON.parse(data);
      var html = "";
      for (var i=0; i < arr.length; i++) {
        html += "<br>" + arr[i].join(":");
      }
      document.getElementById("data").innerHTML = html;
    }
shadow
Privacy Policy - Terms - Contact Us © voile276.org