Generate own HTML for Google Form

2019-05-12 00:32发布

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条回答
狗以群分
2楼-- · 2019-05-12 00:36

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.

查看更多
登录 后发表回答