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\]";
}
}
</script>
<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>
</form>

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

~G

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

Recommended Answers

All 2 Replies

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.

~G

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.