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
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding bbcode to links via checkbox

    I have the following code which is used when a user checks a checkbox, or multiple checkboxes, the checkbox value(s) is passed to a textarea.
    Code:
    "fnDrawCallback": function()
    {
        $('input[type=checkbox]').click(function()
        {
            $('textarea[name=links]').val(
            $('input[type=checkbox]:checked').map(function()
            {
                return $(this).val();
            }).toArray().join("\n"));
    
            $('textarea[name=bbcode]').val(
            $('input[type=checkbox]:checked').map(function()
            {
                return $(this).val();
            }).toArray().join("\n"));
        }
        );
    },
    What I want to do is add the [url ] link [/url] or [code ] url [/ code] before and after the passed url, but I'm completely new to jQuery and no idea how to do it.

    As it is now, the checkboxes pass the URL but I want it to pass it to another textarea with bbcode

    EG:
    Textarea 1
    [url =hxxp://www.domain.com]hxxp://www.domain.com[/url]
    [url =hxxp://www.domain2.com]hxxp://www.domain2.com[/url]

    Textarea 2
    hxxp://www.domain.com
    hxxp://www.domain2.com

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Change this:

    Code:
    return $(this).val();
    with:

    Code:
    return '[url]' + $(this).val() + '[/url]';
    Do the same thing for bbcode and use [code] [/code] instead of [url] [/url]
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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