LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Saturday, November 30, 2019

テキストエリアのheightを入力文字数によって自動調整したい


テキストエリア内で折り返しされた時にheightを自動で変更したくて書きました。


デモ





コード.gs
function doGet() {
  return HtmlService.createHtmlOutputFromFile("index");
}
意訳
この機能がやること
指定したHTMLファイルを表示する




index.html
<!DOCTYPE html>
<html>
  <body>
  <textarea id="ta"></textarea>
    <script>
      var ta = document.getElementById("ta");
      ta.oninput = taInput;
      
      function taInput(e){
        ta.style.height = "1em";
        if(ta.scrollHeight > ta.offsetHeight){   
          ta.style.height = ta.scrollHeight + "px";
        }
      }
   </script>
  </body>
</html>


Latest post

スプレッドシートA列にある複数のテキストをスライドに追加したい(Google Apps Script)

今回Google Apps Scriptでやりたいこと GoogleスプレッドシートA列にある複数の値を取得して Googleスライドに渡して 図形オブジェクトのテキストとして追加したい ① スプレッドシートのA列に値を入れておく ② Code.gsのinsertNewShape...