Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Tags around selected text and on mouse cursor.

    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:
    Code:
    function lolwut(txt)
    {
    	var ta = document.getElementById("my_ta");
    	ta.value += txt;
    }
    
    window.onload = function()
    {
    	lolwut("");
    }

  • #2
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts
    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

    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.

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •