How to make a WYSIWYG editor in PHP -
I am trying to create a WYSIWYG editor in PHP. So far I got this (I have a new beta):
HTML:
& lt; Form action = "method =" POST "& gt; & Lt; Select name = "font size" onchange = "this.form.submit ();" & Gt; & Lt; Options & gt; Font size & lt; / Options & gt; & Lt; Option value = "14px" & gt; 14px & lt; / Options & gt; & Lt; Option value = "24px" & gt; 24px & lt; / Options & gt; & Lt; Option value = "34px" & gt; 34px & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Form & gt; & Lt; Form action = "" method = "post" & gt; & Lt; Textarea name = "bodyText" style = "width: 500px; height: 200px; font-size: & lt ;? php echo $ fontSize ;; & gt; & Gt; & Lt; / Textarea & gt; & Lt; / Form & gt;
PHP:
& lt ;? Php $ fontSize = $ _POST ['fontSize']; Switch ($ fontSize) {case "14px": $ fontSize = "14px"; break; Case "24px": $ fontSize = "24px"; break; Case "34px": $ fontSize = "34px"; break; Default: $ fontSize = "12px"; }? & Gt;
The problem is that when I select the font size new font size for the entire font field change from the drop-down menu, then I can be able to highlight a particular word or letter. I just want to change that font size and not the whole text area. How about this?
You can do it (theoretically), but users have to use it happy with it The problem is that, every time, a button is pressed, the page gets refreshed, which means that the content of the form is sent to the server, it is modified and sent back.
Just changing the font for Reaction time is a long way . The user will not work comfortably with this editor.
In fact, using a JS WYSIWYG editor, which is the client side (in which other answers are linked).
Specifically what you have asked, namely to change only the highlighted text, is not trivial to solve You may be able to do this by sending two additional fields, which Let's start the end point of the highlighted text. They have to be updated by JS.
You can not get it without JS. As already stated, the text has been modified on Server Side .
Do yourself a favor and do not try to do it You have no possibility of finding out what the user is doing using text only. It is not really worth the effort.
Comments
Post a Comment