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 : 377x

Comments for Dynamically resizing height of textarea

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