sford999 Posted April 24, 2013 Share Posted April 24, 2013 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. "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 or 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 text area with bbcode EG:Textarea 1http://www.domain.com Textarea 2[url ]http://www.domain.com[/url] Link to comment https://forums.phpfreaks.com/topic/277260-adding-bbcode-to-links-via-checkbox/ Share on other sites More sharing options...
sford999 Posted April 27, 2013 Author Share Posted April 27, 2013 Anyone? Link to comment https://forums.phpfreaks.com/topic/277260-adding-bbcode-to-links-via-checkbox/#findComment-1426843 Share on other sites More sharing options...
Jessica Posted April 27, 2013 Share Posted April 27, 2013 In javascript you concatenate strings with + If you have the string you want to add the code to, just do "http://"+url+"" Link to comment https://forums.phpfreaks.com/topic/277260-adding-bbcode-to-links-via-checkbox/#findComment-1426866 Share on other sites More sharing options...
sford999 Posted April 28, 2013 Author Share Posted April 28, 2013 I figured it out as i changed the code to: "fnDrawCallback": function() { $('input[type=checkbox][name=links]').click(function() { $('textarea[name=links]').text(''); $('input[type=checkbox][name=links]:checked').each(function() { $('textarea[name=links]').append( $(this).val() + '\n'); }); }); $('input[type=checkbox][name=links]').click(function() { $('textarea[name=bbcode]').text(''); $('input[type=checkbox][name=links]:checked').each(function() { $('textarea[name=bbcode]').append('[code]' + $(this).val() + '[/code] \n'); }); }); }, Link to comment https://forums.phpfreaks.com/topic/277260-adding-bbcode-to-links-via-checkbox/#findComment-1426934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.