'How can I use JavaScript to update text at the cursor location inside a textbox
I'm developing in asp.net and have a textbox on the screen with the cursor at a location that some text should be added.
A button exists on the page, or at least it will do and when pressed will insert text into the textbox at the location the cursor was at the point the button was pressed, no text should be lost only a keyword added at the location of the cursor.
Is this possible to in JavaScript, bearing in mind I don't know any JavaScript beyond alert(''); and I do understand when you click the button the cursor location may be lost.
There will actually be seven little buttons each inserting a different string of their own.
Solution 1:[1]
See this answer for a few pointers.
The short version is "yes, it is possible, at least with recent browsers". However, you will need to teach yourself some JavaScript to get this working. I personally recommend this online book (and am in no way affiliated with the author).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
