google apps script - HTML Service - Dropdown option list from GSheet -


into google apps script , html service

code.gs  function doget() {   return htmlservice.createtemplatefromfile('htmlui').evaluate()   .setsandboxmode(htmlservice.sandboxmode.native); } 

here html

htmlui.html  <script type="text/javascript"></script> <script> <?   var sheet   = spreadsheetapp.openbyid("0avt7ejriwlxudgzfv2xjugjzlxktq2rhqu1urugtaxc").getsheetbyname("mrf tab");   var lastrow = sheet.getlastrow();     var myrange = sheet.getrange("c3:c"+lastrow);    var data    = myrange.getvalues(); ?> </script> <select> <? (var = 0; < sourcedata.length; ++i) { ?> <option><?!= sourcedata[i] ?></option> <? } ?> </select> 

i had code in 1 of project (and lot more code) captures information form sheet , add options (dropdown) in select, when trying same code in new project isnt working, ideas missing.

at present result displayed dropdown box <?!=sourcedata[i]?>

how can correct this. please.

edit:---

please have @ comment no 3 link spreadsheet , workaround it...

the results describe result of nested templated html - it's clear evaluator isn't designed handle it, unevaluated scriptlets being shown text.

you're using templated html in test.html include templated html htmlui.html, , include() function tries treat content of htmlui.html regular (non-templated) html source.

one way around use version of include() templated html. put in gs file:

function includetemplate(filename) {     return htmlservice.createtemplatefromfile(filename).evaluate()       .setsandboxmode(htmlservice.sandboxmode.native)       .getcontent(); } 

your test.html becomes:

<?!= includetemplate('htmlui'); ?> 

this accomplish you're trying in example. so, though, you're losing of capabilities of templated html, not have opportunity push variables template.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -