Generate own HTML for Google Form

2019-05-12 00:05发布

问题:

I like to generate the Google Form using my own template engine. Unfortunatelly in the basic theme you can change only the background image, fonts, color etc is allowed. I like to have a nice HTML page in "bootstrap" style. So far I can see I could do this using Google Script. The script should open the form and generate HTML template (like example below).

Does someone know how to generate correctly this form? Which url to submit should I use? Hidden parameters?

Thanks for any comments.

Code.gs

function doGet() {
  return HtmlService
      .createTemplateFromFile('index')
      .evaluate();
};

function getData() {
  var form = FormApp.openById('....................');
  return form;
}

index.html

<? var data = getData(); ?>
<? var items = data.getItems(); ?>

<form action="https://docs.google.com/forms/d/..................../formResponse" method="POST">
<!-- .................... stands for form id //-->
<ul>
  <? for (var i = 0; i < items.length; i++) { ?>
    <li><?= items[i].getTitle(); ?></li>
  <? } ?>
</ul>
<input type="submit"/>
</form>

回答1:

You can use this Google Form HTML Exporter tool http://stefano.brilli.me/google-forms-html-exporter/ all you have to provide is link to the Google Form.