SC__Programmer Posted November 16, 2011 Share Posted November 16, 2011 I'm trying to change the textarea's value into pure html. So like if a textarea has this, Test Test I want to change it to html all on one link like this, Test<br><br>Test How would i do that?ive looked at WYSIWYG editors but they're to much coding for what i want. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 16, 2011 Share Posted November 16, 2011 Pure HTML for display purposes? Use CSS's white-space:pre. Otherwise PHP has nl2br, which you can emulate using regular expressions in other languages. Quote Link to comment Share on other sites More sharing options...
SC__Programmer Posted November 16, 2011 Author Share Posted November 16, 2011 That isnt working,ill explain it better I have some HTML in a mysql database like <div>Test<br>Test</div>,i want to be able to display that like this, <div>Test Test</div> Then save it back in the database like this, <div>Test<br>Test</div> Quote Link to comment Share on other sites More sharing options...
requinix Posted November 16, 2011 Share Posted November 16, 2011 Save two copies of the text: one without (or with minimal?) HTML and one fully translated into HTML. One gets edited and the other gets displayed. Quote Link to comment Share on other sites More sharing options...
SC__Programmer Posted November 16, 2011 Author Share Posted November 16, 2011 How? Im trying to make a homepage welcome thingy,in the admin panel you have a textarea box where you edit the text.when i load the value of the database(Test<br><br>Test) it shows up in the textarea as Test<br><br>Test,i want it to show up as Test Test and when the user gets done editing its going to be like this Edited Edited and when they push save i want it to convert to Edited<br><br>Edited so i can save it to the database. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 17, 2011 Share Posted November 17, 2011 How? Are you storing the text in a database? Quote Link to comment Share on other sites More sharing options...
bspace Posted November 30, 2011 Share Posted November 30, 2011 do you mean you want to use a WYSIWYG Editor on a form field? if so have a look at ckeditor or tinymce Quote Link to comment Share on other sites More sharing options...
haku Posted December 3, 2011 Share Posted December 3, 2011 Save the data as-is to the database. Before printing it to the screen, run the text through the php nl2br() function. When you are putting the data into a textarea, you won't have to do anything, as you save it in its original form in the database, so putting it back in a textarea will make it exactly the same as it was before it was saved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.