Solved

Resize textare field as text is entered

Posted on 2014-01-21
8
215 Views
Last Modified: 2014-01-21
The solution here works for changing the height dynamically.

http://jsfiddle.net/FNMSP/2/

1.  I need it to auto-shorten the height of the textarea when text is erased (the reverse of what is doing now )

2. I also need that the width of the textarea resizes automatically (shorten or  lenghten)
So it will enlarge till reaching a max-width, then will start increasing the height.

Thank you!
0
Comment
Question by:myyis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39797648
Since you are using MooTools
http://mootools.net/forge/p/form_autogrow

For the width - that would be an unusual one since the textarea would automatically wrap so there is no defined width to calculate.
0
 

Author Comment

by:myyis
ID: 39797720
Is it possible with pure JS?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39797733
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:myyis
ID: 39797754
I don't use jquery
0
 
LVL 58

Expert Comment

by:Gary
ID: 39797808
http://jsfiddle.net/GaryC123/eq554/5/

<textarea onkeyup="autogrow(this)"></textarea>
<style>
textarea {
    min-height:50px;
    overflow:hidden;
}
</style>
<script>
    function autogrow(textField) {
    rows = textField.value.split("\n").length + 1
    textField.style.height = (rows * 14) + "px";
    }
</script>

Open in new window

0
 

Author Comment

by:myyis
ID: 39798433
Thank you it is very like to what I wanted to do.
The only problem is that if I don't use enter button and keep writing it does not work.
Any idea?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39798466
0
 

Author Comment

by:myyis
ID: 39798534
great! thank you.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question