1

I need to create a web form that sends input data to a Google spreadsheet. I am following the instructions on this medium post [Post 1]

I also found this one on github which is by and large the same but used doPost instead of doGet. [Post 2]

I managed to get the form to open a new tab and the URLs showed all input as URL parameters. But the spreadsheet didn't get any data written in.

I've also tried to follow the instructions using doPost (Post 2) with similar results.

My Code.gs looks exactly the same as the one in Post 1, with the exceptions of the file name because I have other scripts for this spreadsheet. Also I updated the Sheet_NAME value.

I made sure my first row in the sheet receiving inputs have the id and name attributes I want to put in the html file. I copy/paste my html file into a Google site. My html file looks like similar to this, with the right web app URL:

<!DOCTYPE html>
<html>
  <head>
    <style>
      /* A bunch of style specifications */
    </style>
  </head>
  <body>
   <form id="intake-form" name="intake-form">
     <div class="form-group">
       <label for="fied1Name">Feature 1 Name/label>
       <input class="form-control" type="text" id="fied1Name" name="fied1Name"/>
     </div>
     ... more fields here
     <div>
       <button type="submit" id="submit-form">Submit</button>
     </div>
   </form>
  <script>
  var $form = $('form#intake-form'),
               url = 'https://script.google.com/a/google.com/macros/s/.../exec'

  $('#submit-form').on('click', function(e) {
  e.preventDefault();
  var jqxhr = $.ajax({
    url: url,
    method: "GET",
    dataType: "json",
    data: $form.serializeObject()
  }).success(
    $form..reset();
    return true
  );
})
</script>
</body>
</html>
Kay Chen
  • 11
  • 1
  • 4

0 Answers0