February 2, 201313 yr Alright, so I've already pestered this forum with a couple questions already, but I (hopefully) have one last problem that I can't seem to find any tutorials or information on... I have two text areas, each which need a maximum length of 200 characters. I would like it so that when the character limit is exceeded on the first text area, it spills over into the second. I should also note, these text areas are being populated by the values of other text inputs, using the following Javascript: <script type="text/javascript"> <!-- var textB1 = "value one: " ; var textB2 = "value two: "; var space = "\n"; function xferText() { document.getElementById("textB").value=textB1 + document.getElementById("text").value +space +textB2 +document.getElementById("textA").value; } window.onload = function() { document.getElementById("textB").value=textB1 + textB2; } //--> </script> And the HTML: <div> <input type="text" id="text" /> </div> <div> <input type="text" id="textA" /> <div> <textarea id="textB"></textarea> </div> <div> <textarea id="textC"></textarea> </div> </div> <button onclick="xferText();">Transfer Text</button> </div> Edited February 2, 201313 yr by wellerweb
February 2, 201313 yr What you essentially need to do is put together a string with that combination of values, check it's length and if it's too long, populate a second string with the extra bit before reducing the size of the first string. I've put together an example showing how to do this, feel free to use it: Skateside's example
Create an account or sign in to comment