Jump to content
  • 0

text area auto size (vertically)


DavidBRX

Question

Is there a way to make this field "auto size" itself based on content entered? If I make the rows to large and only use two roes, it requires huge scrolling within a tiny window frame. If I select 20 rows (as shown) and only enter two rows of data/text, there's a huge open area below. :-(

It would e nice to have it expand/contract as content is entered.  Not sure if such java code even exists as I've tried searching teh internet with no avail. :-(

See attached.
1634297

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @DavidBRX. You may try the code below. Add a header and footer on your datapage and disable the HTML editor:

 

Header:

<style>
.cbFormTextArea {
  resize: none; 
  overflow: hidden;
}
</style>

 

Footer:

<script>
document.addEventListener('input', function (event) {
  if (event.target.tagName.toLowerCase() !== 'textarea') return;
  autoResize(event.target);
}, false);

function autoResize(textarea) {
  textarea.style.height = 'auto';
  textarea.style.height = textarea.scrollHeight + 'px';
}
</script>

 

-Potato

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...