DedeCMS后台系统参数里的多行文本框自动高度

我想用DedeCMS后台-系统配置参数下的多行文本框,用来记录一些网站维护信息,如果文字太多,超出的文字就隐藏了,需要下拉才能看到下面的文字,按照以下修改,可以让它自动放大文本框。

修改前:

修改后:

详细步骤:

打开文件/dede/templets/sys_info.htm

定位到185行:

echo "<textarea name='edit___{$row['varname']}' row='4' id='edit___{$row['varname']}' class='textarea_info' style='width:80%;'>".dede_htmlspecialchars($row['value'])."</textarea>";

修改成:

echo "<textarea name='edit___{$row['varname']}' id='edit___{$row['varname']}' class='textarea_info auto-resize' style='width:80%;'>".dede_htmlspecialchars($row['value'])."</textarea>";

在页面底部加入:

<script>
  document.querySelectorAll('.auto-resize').forEach(textarea => {
      textarea.style.height = 'auto';
      textarea.style.height = textarea.scrollHeight + 'px';
      textarea.addEventListener('input', function() {
          this.style.height = 'auto';
          this.style.height = this.scrollHeight + 'px';
      });
  });
  </script>