Code solutions to PHP, JS, CSSCode source PHP, JS, CSS

Spread your code soluces to the world

Love me
Solucior » JAVASCRIPT » Dynamically resizing height of textarea

Dynamically resizing height of textarea

05/13/2011 by Dux   -   3.9/5 (23 ratings)

This code dynamically resize a textarea according to its contents. It can work when the textarea gains focus and during typing.


source code

<script type="text/javascript">
haut(idt) {
   if (
document.getElementById(idt).scrollTop > 0) aug(idt);
aug(idt) {
h = parseInt(document.getElementById(idt).style.height);
document.getElementById(idt).style.height = h + 10 +"px";
top(idt) {
document.getElementById(idt).scrollTop = 100000;

<textarea name="txt_test" style="width: 700px; height: 150px" id="txt_test" onkeyup="javascript: haut(" onfocus="javascript: top("></textarea>

Tested with Safari  Google Chrome  Firefox3  Firefox4  
Rate this code     |     Copied : 408x

Comments for Dynamically resizing height of textarea

suba suba     12/20/2018 02:23
DtPvdq style is awesome, keep doing what you are doing!
suba suba     12/20/2018 00:00
qZmXWJ they have been a moment to consider taking a shot?
mia pron khalifa     12/19/2018 15:38
feYm9S You have made some really good points there. I checked on the internet for additional information about the issue and found most people will go along with your views on this web site.
i love pron     12/17/2018 08:48
du8UxW Wow, amazing weblog structure! How long have you been blogging for? you make blogging glance easy. The full glance of your site is magnificent, let alone the content!
suba suba     12/17/2018 06:49
UihOPc Thanks for sharing, this is a fantastic blog post.Thanks Again. Really Great.
see pron     12/17/2018 00:24
woy12y Thanks-a-mundo for the post.Really thank you! Awesome.
suba me     10/11/2018 20:03
e7Mkwb Thank you for your blog.Thanks Again. Fantastic.
suba pron     08/12/2018 17:38
Y2QBd1 It is really a nice and helpful piece of information. I am satisfied that you simply shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
subastian     11/27/2016 08:28
Am5aQ2 This is a terrific website. and i need to take a look at this just about every day of your week ,
suba bob     11/27/2016 00:29
lbLMfy Informative and precise Its difficult to find informative and precise info but here I found
Yep     05/07/2015 01:38
C'est bien. Si on pouvait l'améliorer afin de réduire la taille quand le contenu diminue, ce serait interessant.
Johnd625     11/25/2014 10:26
I really enjoy the article post. Cool. dadekdafeefd
Johnd356     11/25/2014 10:26
Im not that much of a online reader to be honest but your blogs really nice, keep it up! I'll go ahead and bookmark your site to come back later. All the best eecgbeeaekge
Yep     05/23/2013 15:23
Thx mais si tu rajoutes une ligne avant la dernière ligne ça taff pas
pipe     03/20/2013 18:34
Tab     12/03/2012 15:39
Thank you
SaïB     06/26/2012 08:09
Merci pour ce code
Thanks for this code, very helpfull
octameter     06/11/2012 21:04
nice workaround! thx octameter
Add a comment Nickname   Site