...

View Full Version : highlight text, click on a button and add bbCode in textarea



jeskel
11-06-2004, 06:30 PM
Hi :)

first steps in the world of javascript.
You can guess that it's still a dark world to me. :)

Here is what I am trying to do.

I have a textarea and a little image (the common 'B' for Bold). I would like, as the title of this thread suggests, that when I click on the image, the highlighted texts become surrounded by these two custom bbCode: [ b ]text highlighted[ /b ] (extra spaces have been added so that vbulletin does not actually interpret the bbcode ;)).
Is that hard to achieve? Would someone show me how to do this?
That would be really nice.

Here is my actual code (just the fundations of the page). You will find the gif in question in the attachement part of this thread. I am looking forward to learning how to do this.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>playing with the textarea</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<script type=text/javascript>

</script>

</head>
<body>


<form name="replace" id="replace" action="" method="">

<img height=20 alt=Bold src="bold.gif" width=21>
<br />
<textarea name="test" rows="20" cols="35"></textarea>
<br />
<input type="submit" value="Submit" />

</form>

</body>
</html>


thanks in advance for your help :)

Willy Duitt
11-06-2004, 08:01 PM
This has been asked and answered several times...
Try searching the forum for bbCode in* textarea....

jeskel
11-06-2004, 11:46 PM
This has been asked and answered several times...
Try searching the forum for bbCode in* textarea....
Hi :)
thanks for your reply.
I tried but couldn't find the answer. I always end up in the middle of already advanced projects, therefore I don't get nothing to the discussion that is going on.
Do you have a link to a thread that is starting it from scratch?
Basically, I just need to get bold, italic and a few other edition tools to work,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum