akumakeenta Posted March 7, 2010 Share Posted March 7, 2010 I'm sure there have been those with this same problem. I have a script that will not process HTML inside of a text box form. I would like to type <b>bold</b> and that it come out bold instead of literally <b>bold</b> What should I look for in the php script? Is there something that they wrote in the php to strip the HTML code (make it literal code)? or do I have to add php code to make it process the HTML? Thanks for all your help in advance. Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/ Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 What your looking for needs to be done client side (where the form is) via Javascript. PHP can't help you here as it is processed on the server. Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/#findComment-1022560 Share on other sites More sharing options...
akumakeenta Posted March 7, 2010 Author Share Posted March 7, 2010 So I should be looking for javascript then? Any chance you know what key words i should be looking for in the javascript? Thanks again. Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/#findComment-1022563 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 Sounds like your looking for a WYSIWYG editor. Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/#findComment-1022568 Share on other sites More sharing options...
vividona Posted March 7, 2010 Share Posted March 7, 2010 function bbcodes($message) { $pattern[] = '#\[b\](.*?)\[/b\]#s'; $pattern[] = '#\[i\](.*?)\[/i\]#s'; $pattern[] = '#\[u\](.*?)\[/u\]#s'; $pattern[] = '#\[quote](.*?)\[\/quote\]#is'; $pattern[] = '#\[quote=(.*?)\](.*?)\[\/quote\]#is'; $pattern[] = '#\[font=(.*?)\](.*?)\[/font\]#s'; $pattern[] = '#\[size=(.*?)\](.*?)\[/size\]#s'; $pattern[] = '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s'; $pattern[] = '#\[left\](.*?)\[/left\]#s'; $pattern[] = '#\[center\](.*?)\[/center\]#s'; $pattern[] = '#\[right\](.*?)\[/right\]#s'; $pattern[] = '/\[img\](.*?)\[\/img\]/is'; $replace[] = '<strong>$1</strong>'; $replace[] = '<em>$1</em>'; $replace[] = '<u>$1</u>'; $replace[] = '<div class="quote"><div class="quotetext">$1</div></div>'; $replace[] = '<div class="quote"><div class="quotename">$1</div><div class="quotetext"><p>$2</p></div></div>'; $replace[] = '<span style="font-family: $1;">$2</span>'; $replace[] = '<span style="font-size: $1pt;">$2</span>'; $replace[] = '<span style="color: $1">$2</span>'; $replace[] = '<div style="text-align: left;">$1</div>'; $replace[] = '<div style="text-align: center;">$1</div>'; $replace[] = '<div style="text-align: right;">$1</div>'; $replace[] = '<img src="$1" />'; $message = preg_replace($pattern, $replace, $message); return $message; } It will replace xxxxx => <b>xxxx</b> Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/#findComment-1022570 Share on other sites More sharing options...
trq Posted March 7, 2010 Share Posted March 7, 2010 It will replace xxxxx => <b>xxxx</b> Not within a textarea it won't. This needs to be done client-side. Link to comment https://forums.phpfreaks.com/topic/194394-html-doesnt-process-inside-of-text-field/#findComment-1022572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.