Default values [solved]
Added by Alvaro Aribau 6 months ago
Hi again¡
I´m having a little trouble with the editor, I use a form which sends info to another php, then I check if the 2 fields aren´t empty
if($ _ POST['title']!="" && $ _ POST['editor']!=""){}
And then, if one of those are empty I show the same form with the values i´ve received (ex:)
<form name="form" id="form" method="post"> <input type="text" name="title" id="title" value="<?=$_POST['title']?>"> <div id="editor">< ? =$_POST['editor']?></div> </form>
In this case, it doesn´t work properly, because on the editor it shows the text but looses styles. If I make a jscript alert it shows
<span style="color:#336600">asdfasdfasdf<br>asdf<br>sadf<br>sdaf<br>asdf<br>sdf<br>sdaf<br>sadf<br>sdaf<br>asd<br>fasdf<br>asdf<br>asdf<br>sadf<br>asdf</span>
And if I write the form this way (without using php echo) works well:
<form name="form" id="form" method="post"> <input type="text" name="title" id="title" value="< ? =$_POST['title']?>"> <div id="editor"><span style="color:#336600">asdfasdfasdf<br>asdf<br>sadf<br>sdaf<br>asdf<br>sdf<br>sdaf<br>sadf<br>sdaf<br>asd<br>fasdf<br>asdf<br>asdf<br>sadf<br>asdf</span> </div> </form>
Why is this happening?
Shuld I have to give a value to the editor via javascript when it´s all loaded?
Thanks in advance, and sorry for my bad english.
(i´ve wrote the php symbols with spaces because parser deletes them if are correct)
Replies (3)
RE: Default values
-
Added by Alvaro Aribau 6 months ago
I´ve found solution here:
http://stackoverflow.com/questions/6693083/how-to-set-value-of-elrte-editor
Thanks anyway¡
RE: Default values [solved]
-
Added by Troex Nevelin 6 months ago
I don't know why your example is not working, probably problem not in elRTE, but setting content from PHP e.g. generated in html should cause no problem.
Any way I'm glad you found a solution
RE: Default values [solved]
-
Added by Alvaro Aribau 6 months ago
I think that the problem was caused by the special chars / " \ and spaces, not sure about if was an elrte problem, but the content of $_POST isn´t modified before giving the value to editor.
I solved it in firefox using a jscript function that gives the value to editor when all is complete via php.
But the problem was IE, it doesn´t take the php directly, so I had to parse the chars I said before because jscripts fails when sees an space or a special char.
I had to give the value to a hidden input and then take it via jscript, unparse and use it in a function that gives the value to the editor.
I think there must be a easier solution, but mine works perfect now. I can add my code if needed.
Thanks¡
(1-3/3)