Text Formatting

JavaScript and client side scripting.

Moderator: General Moderators

phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Text Formatting

Post by phppick »

Hi,

I want Use Textarea with Formatting Options (like Bold, Italic etc etc)
Let say like this textarea in forum 'new topic posting'

Where can i get like this. i want this to be work in multi OS..

Like:
--------
Company Name

Street

Some text ,text text text text text
text text
text
---------

And with paragraphs

Any body can help me??

Thanks
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You want the buttons and stuff for adding the bbcode? Have you had a look in the source code of the page?

Mac
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

For something really advanced look at this

http://www.fredck.com/FCKeditor/

for a demo, look here http://www.fredck.com/FCKeditor/Demo/

Mark
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Hi twigletmac - Text format

Post by phppick »

Hi twigletmac

Sorry for cross post.. So, i can download BBCode from sourceforge.net

And main issue is, i am entering some text as Paragraphs in text area. to store it in database i am using datatype 'text' .

But while displaying, its showing as one paragraph. Suppose if paste some content from BBC news website and if contains some 5-6 paragraphs, while displaying it to the user , Its showing as only one paragrpah. All the text in one para..

Can you help me on this??
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

i'll give u a example:

Code: Select all

<?php
$sql = "select * from table_name";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$comment = nl2br($row["comment"]);

?>
focus your attention on the nl2br, this will give your line breaks =]

cheers
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

nl2br() function will fix that :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

beat me to the punch.. :P
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

lol i been beat my fair share of times here...

I hate hitting that edit button! :oops:
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Thanks

Post by phppick »

Hi,

Thanks for your solution TIM.its working great.

Anyway you have any idea how to Implement BBCODE, in my page? i wnat exactly like in this Forum.. Bold, Italic etc..

Thanks.

Jen
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

before showing the threads and replies, the post goes trough a "format"-function, which changes bbcode into the HTML. you could just use [php_man]str_replace[/php_man], but also [php_man]preg_replace[/php_man] using regexp patterns...
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

couldnt have said it better myself.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

on second thought

I remember a post and the guy wanted to do exactly what u wanted, the code and how-tos was on it

search for it if all else fails here.
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

BBCODE

Post by phppick »

Hi

ANYBODY CAN TELL ME HOW TO USE THIS BBCODE( this Textarea part with Bold and Italic options) Which we use for Posting Replies/Newpost..
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i already posted how...
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

alternatively, you can use a ubb function on phpclasses.org - it's somewhat buggy and not tremendously effective, but you will get the idea from what is necessary and how to implement it.

Just search for ubb on phpclasses.org.
Post Reply