function autoResizeTextArea () { var rgLines = this.value.split('\n'); var nRows = 1; for (var i=0; i 80) nRows += Math.ceil (rgLines[i].length/80); nRows += rgLines.length; if (nRows > this.rows) this.rows = Math.min (nRows, 30); }