Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Need help with BBCode (http://www.programmingforums.org/showthread.php?t=11073)

metsfan Aug 14th, 2006 5:02 PM

Need help with BBCode
 
I am currently working on making a fully functional forum. The main language being used in the site is Java, along with the struts framework. However, the BBCode is something that i have been told needs to be done in javascript, so here I am.

in an attempt to make somethign happen, i made the following code:

:

<script language="javascript">

function addBBCode()
{
        var body = document.forms[0].body.value;
        body.value += "b][/b"; //had to remove the tags on the outside because it conflicts with this forum's BBCode
       
        document.forms[0].body.value = body.value;
}

</script>


and also made this button

:

<input type="button" onclick="javascript:addBBCode()" value="B" />

It is not working, but since i have no error messages of any kind i have no idea whats wrong.

I want to make the BBCode work similarly to how it works on these forums. Does anyone have any good links that could be helpful, or perhaps some code snipets that would possibly push me in the right direction? I have very little experience with javascript, but I pick up quickly.

I would also like to note that the backend of the BBCode, that is the parsing of the code and making it happen all works, im just trying to find a way to insert the BBCode into the text box with buttons. If i were to enter the BBCode manually it would work, but naturally this is not sufficient for a fully functional professional forum.

thanx in advance

Ooble Aug 14th, 2006 5:53 PM

You're simply appending [b][/b] to the text. Try this:
:

body.value = "[b]" + body.value + "[/b]";
Let us know how it goes.


All times are GMT -5. The time now is 3:54 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC