Facebook style text area
During my small developing life I found how noisy to type in text area input control where you need to scroll to see data which make my web application users some time fell annoyed by this control especially in cases where you can’t use fancy text editor controls so I found face book site solved with simple and easy way by making this control in some way more dynamic depends on it content so I write following java script that convert all text area controls in page that include this script into face book text area style.
I will add code explenation later enjoy this code:
var defaultRowsCount = 2;
window.onload = function() {
//alert(getTextAreaElements().length);
elements = getTextAreaElements();
for(index = 0; index < elements.length; index++)
{
setTextAreaLength(elements[index]);
elements[index].onkeyup = elements[index].onchange = textAreaLength;
}
}
function textAreaLength(e)
{
setTextAreaLength(this);
}
function getTextAreaElements(){return document.getElementsByTagName(”textarea”);}
function setTextAreaLength(element)
{
data = element.value;
rows = data.split(’\r\n’).length
if(rows >= defaultRowsCount)
element.rows = rows;
else
element.rows = defaultRowsCount;
}

