title: Google Script to Fill out HTML Form
body: <p>I have created a script in google scripts, to take a spreadsheet and fill out multiple google docs successfully. I am trying to apply this logic to filling out an HTML form, basically, we need user-generated info (in our google sheet) to fill out an HTML form on a web page.</p>
  <p>How would I get the following function to not only open but write in the data?</p>
  <p>This is where I am at (just using an example webpage):</p>
  <pre><code>function testNew(){
    var js = &quot; \
      &lt;script&gt; \
        window.open('https://colorlib.com/etc/cf/ContactFrom_v1/index.html', '_blank', 'width=800, height=600'); \
        google.script.host.close(); \
      &lt;/script&gt; \
    &quot;;
    var html = HtmlService.createHtmlOutput(js)
      .setHeight(10)
      .setWidth(100);
    SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.'); // If you use this on Spreadsheet
  //  DocumentApp.getUi().showModalDialog(html, 'Now loading.'); //  If you use this on Document
  //  SlidesApp.getUi().showModalDialog(html, 'Now loading.'); //  If you use this on Slides
  } 
  </code></pre>
  <p>This is an example of what I did with the google docs, trying to replicate in forms:</p>
  <pre><code>function myFunction() {
        var data = Sheets.Spreadsheets.Values.get('google sheet ID HERE', 'A2:R300');
        // google doc template id, already got deal memo
        var templateId = 'google doc ID HERE';
        // loop through the values &quot;i&quot; is looping the rows, &quot;#&quot; is the column example: 0=a,1=b   
        for (var i = 0; i &lt; data.values.length; i++) {
          var date = data.values[i][0];
          var email = data.values[i][1];
          // grab the google doc template, create a copy, and generate the new id
          var documentId = DriveApp.getFileById(templateId).makeCopy().getId();
          // change the name of the new file
          DriveApp.getFileById(documentId).setName(companyName+ '-' + projectName+ '-' + 'Insurance Report');
          // get the document body as a variable
          var body = DocumentApp.openById(documentId).getBody();
          // replace values with google sheet data
          body.replaceText('##Date##', date);
          body.replaceText('##Email##', email);
  </code></pre>