![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2005
Posts: 57
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
You're simply appending [b][/b] to the text. Try this:
body.value = "[b]" + body.value + "[/b]"; |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|