Skip to content

Instantly share code, notes, and snippets.

@samg
Created April 21, 2009 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samg/99346 to your computer and use it in GitHub Desktop.
Save samg/99346 to your computer and use it in GitHub Desktop.
/*
* Scale all textareas dynamically on the page
* Requires Prototype
*/
function scaleTextareas(){
$$('textarea').each(function(t){
t.style.height = Math.floor($F(t).split('\n').inject(1, function(m, s){
return m += (s.length/(t.offsetWidth/10)) + 1;
})) + 8 + 'em';
});
setTimeout(scaleTextareas, 1000);
};
Event.observe(window, 'load', function() {
scaleTextareas();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment