Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 23318
  • Total topics 4048
  • Total members 5574
  • Our newest member
    ALF5583

TOP POSTERS

create autogrow textarea

All problems related to JavaScript and AJAX are discussed and resolved here.
   

create autogrow textarea

Postby zmoerf » Fri Oct 09, 2009 10:48 pm

This plugin makes it easy to have auto-growing textareas. Meaning, if you have a textarea, as the user types it will expand vertically to accommodate the size of the entry. This was inspired by Facebook's auto-expanding text areas.
To make a textarea autogrow, simply do this

1. download jsquery plugin : http://plugins.jquery.com/files/jquery.autogrow-1.0.2.1.zip
2. extract to you localhost folder and crate dome.html file
call jquery javascript
Code: Select all
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.autogrow.js"></script>

crate function javascript
Code: Select all
<script type="text/javascript">
$(document).ready (function() {
   
   $('textarea.expanding').autogrow();
                     
});
</script>

<style type="text/css">
textarea.expanding {
   line-height: 18px;
}

</style>


and then make your textarea form
Code: Select all
<form>
<textarea style="width: 400px; height: 84px; min-height: 84px;" class="expanding" name="myTextarea"></textarea> example 1 <br>
<textarea class="expanding" style="max-height: 100px" name="myTextarea2"></textarea> example 2
</form>


you can see demo : http://www.ajax-tutorial.net/download/jquery/demo/textarea-autogrow/
download file demo have modification: http://www.ajax-tutorial.net/ajax-tutorials/ajax-auto-growing-textarea/
zmoerf
 
Posts: 5
Joined: Fri Oct 09, 2009 10:28 pm
   

Return to JavaScript & AJAX



Who is online

Users browsing this forum: No registered users and 1 guest