I set the width of the text box to 100%, but now I need to know how many characters can fit on one line.
I am trying to write a javascript function to automatically create / compress a text field. I try not to use jquery since I just need this function.
My logic is rows = textarea.value.split('\n'), iterating through rowsand count += rows[i].length/textarea.colsthen count += rows.lengthand finally textarea.rows = count. The only problem is that it is counttoo large because it is textarea.colstoo small.
source
share