I have a button that when clicked writes a text to a specific input box, but I have many input boxes and I would like to set it to write anywhere my cursor is at the moment, or whichever input box is selected. How can I do this?
Asked
Active
Viewed 67 times
0
-
Google for *js get input with focus*, then *js get input cursor position* and finaly *js add char to the middle of string*. I guarantee you these keywords will lead you to the right stackoverflow questions. – Al.G. Aug 27 '17 at 11:36
-
Probable this link will help https://stackoverflow.com/questions/16105482/get-current-cursor-position-in-a-textbox. – atiq1589 Aug 27 '17 at 11:37
1 Answers
0
Idea to solve this problem is
when user click a input box save element reference to a variable including position with help of this link
var elInfo = { el : object, // element reference pos: 0 // current position };
when user click that button retrieve information from the variable and append your text to the element.

atiq1589
- 2,227
- 1
- 16
- 24