I have a page with a lot of textboxes. When someone clicks a link, i want a word or two to be inserted where the cursor is, or appended to the textbox which has the focus.<
using @quick_sliv answer:
function insertAtCaret(el, text) { var caretPos = el.selectionStart; var textAreaTxt = el.value; el.value = textAreaTxt.substring(0, caretPos) + text + textAreaTxt.substring(caretPos); };