I am trying to make a textarea where there is a set maxlength and it is held on one row. Once the maxlength is reached, the textareas attributes need to be targeted so the maxlength is doubled and another row is added.
To see if this could work I tried it just to add an extra row and forty more characters. Here is my code...
<!DOCTYPE html>
<HEAD>
<TITLE>Cool Text Form</TITLE>
</HEAD>
<script language="javascript" type="text/javascript">
function newline()
{
x = document.getElementById("notesfield").length;
if (x >= 40)
document.getElementById("notesfield").rows="2";
document.getElementById("notesfield").maxlength="80";
}
</script>
<textarea id="notesfield" maxlength="40" rows="1" onkeyup="newline()" class="notes">Notes go here.</textarea>
The problem is, this code does not work. I have tried it and once the maxlength is reached, nothing happens. Also, there were no errors in the javascript console of chrome. Can anyone help me get this working or point me in the right direction?
Thanks!