Reputation: 143
In my phpmyadmin, I can see that the linebreaks or carriage returns are recognized in the database entries however when they are displayed on the website, the carriage returns are ignored and everything is joined together.
Right now I have the text aligned to the left. I don't know if that is the reason for this.
I tried to get the keystrokes then if 13 or carriage return was entered, store a <br>
instead or something... I even tried manually enterring
and /r/n
but those are also ignored, they are stored in the db.
So what can I do?
Here is what I tried briefly regarding the replace
function build_post() {
this.value = "";
}
var message = new build_post();
function addtomessage(fnc, keynum) {
fnc.value = message.value + keynum;
}
function myKeyPress(e) {
var keynum;
if (window.event) { // IE
keynum = e.keyCode;
} else if (e.which) { // Netscape/Firefox/Opera
keynum = e.which;
}
count_char();
if (keynum == 13) {
linebreak = '<br>';
addtomessage(message, String.fromCharCode(linebreak));
} else {
addtomessage(message, String.fromCharCode(keynum));
}
}
Then the result is echoed in between the textarea tags
Upvotes: 3
Views: 596