Without seeing your page, it would be difficult to supply the correct code. Here is a demo of the concept:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function setCursorPosition(oInput,oStart,oEnd) {
if( oInput.setSelectionRange ) {
oInput.setSelectionRange(oStart,oEnd);
}
else if( oInput.createTextRange ) {
var range = oInput.createTextRange();
range.collapse(true);
range.moveEnd('character',oEnd);
range.moveStart('character',oStart);
range.select();
}
}
window.onload = function(){
var ta = document.forms[0].elements['bob'];
ta.focus();
setCursorPosition(ta, ta.value.length, ta.value.length);
};
</script>
</head>
<body>
<form action="">
<textarea name="bob" cols="50" rows="5">Hi</textarea>
</form>
</body>
</html>
Bookmarks