<textarea id="txt"></textarea> <script> var str = ""; for (var i = 0; i < 10; i++) str += i + "\n"; document.getElementById("txt").value = str; </script>