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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.