Jump to content

[SOLVED] textarea and div


ricmetal

Recommended Posts

so, the text inside a textarea keeps it's linebreaks from appearing in the db, and in the textarea once brought into it, from the db.

 

the div however, contentEditable, shows its <br>'s and they are stored in the db, and appear in the html when brought in from the db

 

mind you that they are not rendered into the html, they appear as text, but this doesnt happen with the textarea, which keeps its <br>'s hidden

 

how do i make the div imitate this hide effect that the textarea does to hide the <br> from showing, but maintaining line breaks?

 

i red somethign about wrapping the div with pre but i was wondering if there's a fixed solution (that is comonly used) to do what im after.

Link to comment
Share on other sites

Are you using htmlspecialchars or a similar function before storing it?

 

If I'm understanding you correctly, what you'll want to do is store the raw textarea value in the database, then use nl2br() on it on the page to show the new lines (as entered in the textarea).

Link to comment
Share on other sites

just using mysql_real_escape_string before storing

 

fabry

the text from the textarea is displayed correctly. it goes raw to the db and comes out with the line breaks (i use nl2br btw), appearing correctly in the textarea, and html (either way i choose to see it)

 

what i need is for the div to act the same way

 

i am using htmlspecialchars when bringing the data from the db

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.