実現したいこと
スプレッドシートをデータベースとして、動的にhtmlにボタンを作成したいと考えています。
また、作成したボタンのvalueはスプレッドシートの情報を元にした変数を利用したいです。
発生している問題・エラーメッセージ
色々と調べた結果、スプレッドシートのデータを配列に格納し、
配列数に応じたボタンの作成まではできました。
ただ、ボタンのvalueを変数値で設定する方法がわからない状態です。
該当のソースコード
コード.gs function valsget() { let ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("task"); let vals = ss.getDataRange().getValues(); return vals; } function doGet(){ let htmloutput = HtmlService.createTemplateFromFile('index').evaluate(); return htmloutput; } index.html <!DOCTYPE html> <html> <head> <base target="_top"> </head> <body> <table id='ボタン'> <tr> <th>ボタン</th> </tr> </table> </body> </html> <script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"> </script> <script> //webページの読み込み時に実行 window.onload = function(){ google.script.run.withSuccessHandler(function(dt){ for(var i = 0; i<dt.length; i++){ $('#ボタン').append('<input type="button" value="dt[i][0]")>'); } }).valsget(); </script>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/07/10 13:38
退会済みユーザー
2022/07/10 13:41