Forum Moderators: open
Sorry for the poor description of the problem, if you fire the script up in a browser and click foo & newline a few times you understand better :p
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>textarea scroll</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
var keyboard = function () {
var Atags = document.getElementById("foo").getElementsByTagName("li");
for (var t = 0; t < Atags.length; t++) {
Atags[t].onclick = function () {
var theKey = this.innerHTML;
if (this.id == "returnB") theKey = "\n";
document.getElementById("taID").value += theKey;
document.getElementById("taID").focus();
}
}
}
if (window.attachEvent) window.attachEvent("onload", keyboard);
window.onload = keyboard
</script>
</head>
<body>
<textarea id="taID" wrap="off"></textarea>
<ul id="foo">
<li>foo</li>
<li id="returnB">newline</li>
</ul>
</body>
</html>
document.getElementById("taID").scrollTop = document.getElementById("taID").scrollHeight;
document.getElementById("taID").scrollLeft = document.getElementById("taID").scrollWidth;
Just got to sort out the width of text value and use that to scroll left when it reaches the width of the text area.