I have this in my body and it works
onLoad='document.forms.post.message.focus()'
but I need the cursor to be placed in the textarea
at the beginning of any existing text, not at the end. This puts it at the end.
To set the cursor at the end of a textarea: Use the setSelectionRange() method to set the current text selection position to the end of the textarea. Call the focus() method on the textarea element. The focus method will move the cursor to the end of the element's value.
Sometimes all you have to do to make sure the cursor is inside the text box is: click on the text box and when a menu is displayed, click on "Format text box" then click on the "text box" tab and finally modify all four margins (left, right, upper and bottom) by arrowing down until "0" appear on each margin.
Select where you want a new section to begin. Go to Layout > Breaks, and then choose the type of section break you want. Next Page Starts the new section on the following page.
When you click a button you move the focused element so there is no cursor in the text anymore. So you would have to track the last location of the cursor and then just set the value of the text area to be the current value + the extra text at the location of the last know cursor position.
function moveCaretToStart(el) {
if (typeof el.selectionStart == "number") {
el.selectionStart = el.selectionEnd = 0;
} else if (typeof el.createTextRange != "undefined") {
el.focus();
var range = el.createTextRange();
range.collapse(true);
range.select();
}
}
moveCaretToStart(document.forms["post"].elements["message"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With