Jump to content

BBCode buttons


Skullmonkey

Recommended Posts

Hey,I have a project going that I am creating websites for teachers. They all come with a manager so they can edit text w/o having to edit files. I have BBCode in the manage.php file so i dont have to teach them HTML. Right now, I have a table explaining the BBCode but I want to create buttons that they can click to put BBCode in.Anyone know how to do this?MANAGER SAMPLEThanks,Skullmonkey

Link to comment
Share on other sites

here is a very simple one

<html><head></head><body><form action="somefile.php"><input type='button' value='Italic' onclick="txt.value+='[i]ITALIC_TEXT[/i] ';"><input type='button' value='bold' onclick="txt.value+='[b]BOLD_TEXT[/b] ';"><input type='button' value='underline' onclick="txt.value+='[u]UNDERLINE_TEXT[/u] ';"><input type='button' value='url' onclick="txt.value+='[url=URL_TO_GO_TO]TEXT_DISPLAYED[/url] ';"><input type='button' value='color' onclick="txt.value+='[color=COLOR_YOU_WANT]COLORED_TEXT[/color] ';"><input type='button' value='image' onclick="txt.value+='[img=IMAGE_PATH] ';"><input type='button' value='align' onclick="txt.value+='[align=LEFT/RIGHT/CENTER]CONTENT_TO_BE_ALIGNED[/align] ';"><br><textarea cols='100' rows='10' id='txt' name='txt'></textarea><br><input type='submit' value='save'></form></body></html>

Link to comment
Share on other sites

forget the first one, this is betterhere is an example with 2 textareas

<html><head><script type='text/javascript'>function addBB (text, target){	document.getElementById(target).value+=text;}</script></head><body><form action="somefile.php" id="form1"><input type='button' value='Italic' onclick="addBB('[i]ITALIC_TEXT[/i] ', 'txt');"><input type='button' value='bold' onclick="addBB('[b]BOLD_TEXT[/b] ', 'txt');"><input type='button' value='underline' onclick="addBB('[u]UNDERLINE_TEXT[/u] ', 'txt');"><input type='button' value='url' onclick="addBB('[url=URL_TO_GO_TO]TEXT_DISPLAYED[/url] ', 'txt');"><input type='button' value='color' onclick="addBB('[color=COLOR_YOU_WANT]COLORED_TEXT[/color] ', 'txt');"><input type='button' value='image' onclick="addBB('[img=IMAGE_PATH] ', 'txt');"><input type='button' value='align' onclick="addBB('[align=LEFT/RIGHT/CENTER]CONTENT_TO_BE_ALIGNED[/align] ', 'txt');"><br><textarea cols='80' rows='10' id='txt' name='txt'></textarea><br> <br><input type='button' value='Italic' onclick="addBB('[i]ITALIC_TEXT[/i] ', 'txt2');"><input type='button' value='bold' onclick="addBB('[b]BOLD_TEXT[/b] ', 'txt2');"><input type='button' value='underline' onclick="addBB('[u]UNDERLINE_TEXT[/u] ', 'txt2');"><input type='button' value='url' onclick="addBB('[url=URL_TO_GO_TO]TEXT_DISPLAYED[/url] ', 'txt2');"><input type='button' value='color' onclick="addBB('[color=COLOR_YOU_WANT]COLORED_TEXT[/color] ', 'txt2');"><input type='button' value='image' onclick="addBB('[img=IMAGE_PATH] ', 'txt2');"><input type='button' value='align' onclick="addBB('[align=LEFT/RIGHT/CENTER]CONTENT_TO_BE_ALIGNED[/align] ', 'txt2');"><br><textarea cols='80' rows='10' id='txt2' name='txt'></textarea><br><input type='submit' value='save'></form></body></html>

when you call the addBB function, the first argument is the text which you want to add when button is clicked and the second argument is the target textarealike this:addBB('text_to_display', 'target_textarea')you can add as much textareas you want :)btw. this doesn't have anything to do with php, somebody move this thread to javascript forum

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...