kenno69
04-06-2009, 01:20 PM
Hello there
I have a textarea on my website, and when i enter text into it, and if the text has a linebreak in it, it just doesn't read it, and just prints it as 1 line instead of 2 or 3.
Here is the code
<form name="notes"><textarea id="note" cols="40" rows="5"></textarea><br /><input type='button' onclick='UpdateNotes()' value='Update' /></form>
function UpdateNotes(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var note = document.getElementById('note').value;
var ajaxDisplay1 = document.getElementById('ajaxDiv1');
ajaxDisplay1.innerHTML = note;
var queryString = "?action=update¬e=" + note;
ajaxRequest.open("GET", "ajax.php" + queryString, true);
ajaxRequest.send(null);
}
And when i display for example this text
"hello
my friend"
It will display it as hellomy friend
Please help
I have a textarea on my website, and when i enter text into it, and if the text has a linebreak in it, it just doesn't read it, and just prints it as 1 line instead of 2 or 3.
Here is the code
<form name="notes"><textarea id="note" cols="40" rows="5"></textarea><br /><input type='button' onclick='UpdateNotes()' value='Update' /></form>
function UpdateNotes(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var note = document.getElementById('note').value;
var ajaxDisplay1 = document.getElementById('ajaxDiv1');
ajaxDisplay1.innerHTML = note;
var queryString = "?action=update¬e=" + note;
ajaxRequest.open("GET", "ajax.php" + queryString, true);
ajaxRequest.send(null);
}
And when i display for example this text
"hello
my friend"
It will display it as hellomy friend
Please help