﻿

function js_expanding_text_box(mytextarea, mycols, myrows) {

    var thisheight = mytextarea.rows
    var textboxlength = mytextarea.value.length
    var n = mytextarea.value.split(/\n/).length;

    var charrows = (textboxlength - (n * 2)) / mycols;
    charrows = charrows.toFixed(0)

    var contentsheight = n + ((charrows / 10) * 10);

    if (contentsheight > thisheight) {
        mytextarea.rows = contentsheight;
    }

    if (contentsheight < thisheight)
        if (contentsheight > myrows) {
        mytextarea.rows = contentsheight;
    }
    else { mytextarea.rows = myrows; }

}
