View Full Version : Tags around selected text and on mouse cursor.

01-20-2009, 11:21 PM
Hello, I am currently adding BBCode to my website, and I posted a while ago in this forum for a script that would add tags to my textarea when clicking an BBcode image. But my next problem now is that I need those tags to appear around selected text and at the mouse cursor if no text is selected. Currently all it does is just add the tags at the end of your sentence if you've written something in the textarea.

Here is the code I use:

function lolwut(txt)
var ta = document.getElementById("my_ta");
ta.value += txt;

window.onload = function()

01-21-2009, 07:41 AM
Hi Cyber Pirate,

What I find strange is that the quite a few people have written
regexp for the stripping/changing part of the bbcode but I can not find much in the way of help for implementing it on my web page.

What I mean is the javascript side, using those little images to click and wrap around the highlighted text in a textarea.

While it makes sense to customize something for your own page, there seems little point in us all trying to write out the code again.

There must be an example of this somewhere ?

I came across this in a thread search:
to <head> :

<script src="/js/prototype.js" type="text/javascript"></script>
<script src="/js/scriptaculous.js"type="text/javascript"></script>

JS-Libs U can find online.

So there must be some libraries .

I searched and found this:
scriptaculous (http://wiki.github.com/madrobby/scriptaculous)

I hope that helps you.

I am also trying to get a fairly basic wp working for my textareas.
If you make any headway, please share with me.