Jump to content


[javascript]Inserting tags


1 reply to this topic

#1 Slightly Wonky Robob

    Not a Wonky Gent.

  • Administrator
  • 9333 posts

Posted 10 February 2008 - 15:12

I'm creating a BBcode editor, got buttons at the top of a textarea that insert various tags into the textarea, e.g.
[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 :dope:
Posted Image
F O R T H E N S
Posted Image

#2 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 11 February 2008 - 13:47

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/
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users