[javascript]Inserting tags
Slightly Wonky Robob 10 Feb 2008
I'm creating a BBcode editor, got buttons at the top of a textarea that insert various tags into the textarea, e.g.
Now this works fine, however it only inserts the tags at the end of the textarea, there are 2 more things i would like to achieve:
1. Insert the tags at the cursor position, rather the end of the textarea
2. If text is selected, rap the tags around the text.
Help would be greatly appreciated
[b][/b]
Now this works fine, however it only inserts the tags at the end of the textarea, there are 2 more things i would like to achieve:
1. Insert the tags at the cursor position, rather the end of the textarea
2. If text is selected, rap the tags around the text.
Help would be greatly appreciated
CodeCat 11 Feb 2008
It's not really easy because it's not officially supported. Here's a page that might help though.
http://parentnode.org/javascript/working-w...ursor-position/
http://parentnode.org/javascript/working-w...ursor-position/