View Full Version : Dynamic text wrap around TextArea

09-10-2008, 08:56 AM

I can successfully create a textarea which increase in height as you type into it.

However, I have some textarea's which are populated with text from a database table field from SQL Server 2005.

When I try and wrap the textarea around text pulled from my database it doesn't do it. You still have to scroll down to read the text.

Is there any way the textarea can just wrap itself around the text which it pulls from the database?

My code currently looks like this:-

In the head section I have the following code::-

function sz(t) {
a = t.value.split('\n');
for (x=0;x < a.length; x++) {
if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
b+= a.length;
if (b > t.rows) t.rows = b;

In the main body I have the code:-

<textarea onkeyup="sz(this);" rows="40" cols="80" name="appreview" id="appreview" value="<%=objRS("review")%>"></textarea>


09-10-2008, 10:43 AM
<script type="text/javascript">
function sz(t){
var a = t.value.split('\n'), b = a.length;
for (var x = 0; x < a.length; ++x)
if (a[x].length >= t.cols) b += Math.floor(a[x].length/t.cols);
if (++b > t.rows) t.rows = b;
window.onload = function(){sz(document.getElementById('appreview'));};