dexter
dexter

Reputation: 1207

Resize textbox everytime to fit the text length

In my ASP.NET page I have a text box which shows data which is bind to an (JavaScript) object variable. I want that textbox to resize everytime, the JavaScript object, e.g. result.title will change everytime.

Important: I want to fit the textbox exactly to the text length inside.

Upvotes: 1

Views: 2112

Answers (3)

Keith Adler
Keith Adler

Reputation: 21178

Here's a jQuery plug-in: http://www.unwrongest.com/projects/elastic/

Upvotes: 0

UmYeah
UmYeah

Reputation: 820

Here is a great tutorial that teaches you how to make a jQuery plugin to do exactly what your talking about.

Upvotes: 1

watain
watain

Reputation: 5098

You could use onChange:

<textarea onChange="resize(this)"></textarea>

<script>
function resize(el) {
    el.cols = el.value.length;
}
</scrip>

Btw are you using Ajax?

Upvotes: 0

Related Questions