简体   繁体   中英

Making a webapp with listboxes based on Google Spreadsheets with Google Apps Script

Note: This question has been rewritten completely due to changes in my original code.

Hi, I have my Code.gs file and my index.html file. I am trying to create listbox in my index.html file with data from Code.gs.

I did some testing, and the following code gives the results I want:

<select multiple>
<option> <?= articleNumbers(0)[[0]]?> </option>
<option> <?= articleNumbers(0)[[1]]?> </option>
<option> <?= articleNumbers(0)[[2]]?> </option>
<option> <?= articleNumbers(1)[[0]]?> </option>
<option> <?= articleNumbers(1)[[2]]?> </option>
</select>

However, I am making 12 - and counting - listboxes with up to hundreds of values to be inserted from a spreadsheet, so I need to make them with a loop. I tried the following code, hoping the option-tag would go in a loop, but it doesn't seem to work.

<select multiple> 
<? for (i=0; i < 11; i++){ 
        for (j=0; j < articleNumbers(i).length; j++){  ?>  
            <option><?=articleNumbers(i)[[j]]?> </option>
       <?} 
} ?>
</select> 

Any suggestions

Sorry, just realized i forgot the var i and var j . The correct code is as follows

<select multiple> 
<? for (var i = 0; i < 11; i++){ 
      for (var j = 0; j < articleNumbers(i).length; j++){  ?>  
        <option><?=articleNumbers(i)[[j]]?> </option>
   <?} 
} ?>
</select> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM