I'm having a problem with IE, while it works in FF: the var doesn't save any \n aka enter.

I have the following code:

<script type="text/javascript">
function addu() {
var message = window.prompt("Enter the text that needs to be underlined below");
if (message != "" && message != "null") {
document.editform.text.innerHTML += "\[u\]" + message + "\[/u\]";
<img src="beheerimages/ubutton.jpg" onClick="addu()" /><br />
<form name='editform'>
<textarea class="editarea" name="text" cols="100" rows="20"><?php echo $row['bbtext']; ?></textarea>

Does anyone know a answer to this question? As soon as a user presses the ubutton.jpg image, the enters are deleted.


EDIT: the \[ and \] are to prevent the auto-u of daniweb, in the script it is [ and ]

Edited by Graphix: n/a

7 Years
Discussion Span
Last Post by ShawnCplus

Does none of you all know a solution to this problem? Doesn't there exist a special type of variable or a function that saves the enters? Can you atleast give me a tip on how to solve...?

Or do you have a alternative? I am currently searching for a rich text editor that can replace my own script, but i can't seem to find one that is able to be send via the submition of a form.



It does save newlines, but my guess is that on output you're not using nl2br. The browser ignores newlines when rendering text unless it is in a <pre>, <code> or tag with white-space:pre applied. So yeah, use nl2br or get a rich-text editor

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.