Jump to content

Re-Size Textarea


The Little Guy

Recommended Posts

how would I auto size a textarea while the user types?

 

currently I have this, but it doesn't work...

function updateTextBoxHeight(id){
if(id == 'aboutme'){
	var d = document.getElementById("eAbout");
	d.style.height = parseInt(d.style.height) + 12 + 'px';
}
}

 

As the user types it auto re-sizes, but it still does it even if it is not needed. Basically I would like it to work like "Facebook's" method of textarea re-size. The 12 is in there because I want it to have an extra 12 px at the bottom of the textarea.

 

It is triggered by the onkeyup event btw.

Link to comment
https://forums.phpfreaks.com/topic/153684-re-size-textarea/
Share on other sites

Well... I would mostly like to fix my above...

 

If I use this (different than prev):

 

function updateTextBoxHeight(id){
   if(id == 'aboutme'){
      var d = document.getElementById("eAbout");
      d.style.height = d.scrollHeight+'px';
   }
}

 

It works, but when It goes to the next line it shows the scroll bar for a second, then re sizes it, and the scroll bar is gone. I just want to find a way I can fix that so the scroll bar doesn't show up.

Link to comment
https://forums.phpfreaks.com/topic/153684-re-size-textarea/#findComment-808236
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.