1

I want to make it so that if the user has "bold text" highlighted in a text area when they press the "Bold" button it replaces it with "[b]bold text[/b]".

I would think that it would by placing "[b]" before the start of the highlighting and "[/b]" after it.

I already have it so that the when the bold link is pressed it appends "[b]STRING[/b]" to the end of the text area.

the text area is stored in the variable "tbbcearea" so I can call methods on it.

Arcath
  • 4,331
  • 9
  • 39
  • 71

1 Answers1

0

I found this:

http://cfsilence.com/blog/client/index.cfm/2009/7/31/RetrieveReplace-Selected-Text-With-jQuery

this is exactly what i wanted to do

Arcath
  • 4,331
  • 9
  • 39
  • 71
  • Hey Arcath! This link appears to be broken, but I am searching for an answer to this exact question. How'd you do it? – Luke Jan 19 '15 at 01:30
  • I ended up using https://github.com/localhost/jquery-fieldselection but it seems like its not maintained any more – Arcath Feb 03 '15 at 12:44
  • thanks for the reply, You can actually grab the index that the selection starts at with testAreaElement.selectionStart now. So its actually easy, but I'm guessing that the APIs weren't as advanced back in `10. This question has a lot of general info on the matter: http://stackoverflow.com/questions/28055887/is-there-a-flexible-way-to-modify-the-contents-of-an-editable-element/28198957#28198957 – Luke Feb 03 '15 at 18:46