0

I am new to JavaScript, and I'm trying to figure out how to pass values (array) as a parameter to a <script> in HTML code . Here is my code:

function showtestArray() {
  var html = HtmlService.createTemplateFromFile("testArray").evaluate();
      html.arrAta = ["alfa", "beta","gamma","delta","epsilon","omega"];
  SpreadsheetApp.getUi()
    .showModalDialog(html, 'Generator Retete');
}

and here HTML

testArray.HTML
<!DOCTYPE html>
<html>

<head>
  <base target="_top">
</head>

<body>
  <div>
    <select id="arrayDropdown"></select>
    <script>
    //var arr = ["alfa", "beta","gamma","delta","epsilon","omega"];      
      var arr = arrAta;
      var options="";
      arr.map((op,i)=>{
         options+=`<option value="${op}" id="${i}" style="border-radius: 5px;"">${op}</option>`
      })
      document.getElementById("arrayDropdown").innerHTML=options;
    </script>
  </div>
</body>

</html>

if I fix the array in HTML it work, but when try to pass it don't works..

its 2 day i am blocked on it. it's a simple problem but for me is a big problem

0 Answers0