Forum Moderators: open
"\n" '\n' \n - don't work. Neither does \r or \r\n. They just stop the entire funtion working (Mozillia says the function is not defined)
Can anyone help?
<html><head><title>line breaks</title><script type="text/javascript">
// handy proto method
String.prototype.trim = function(){ return this.replace(/(^\s+)¦\s+$/g,"")}function reply(number)
{
number = number.trim() // remove lead + trail spaces
if(!number) return // if empty string, stop
var area = document.comment.commenttext
var addition = "[reply" + number + "]\n";
area.value += addition;
area.focus();
}
</script></head>
<body><form name = "comment">
<textarea name="commenttext"></textarea>
<!-- test stuff -->
<br>
<input type="text" name="testno">
<input type="button" value="test" onclick="reply(this.form.testno.value)">
<input type="button" onclick="this.form.reset()" value="reset">
<!-- / -->
</form>
<br>
<div style="font-family:verdana;font-size:13px; width:400px;">
<p>
#1 Best not call the form and an element by the same name
(..it looks like you are).
For reasons..., you can get away with it, but it's generally
not so good an idea. :)</p>
<p>
#2 As the new input is added below the last,
you don't need the cache. You can simply
append the input onto the current contents.</p>
</div>
</BODY></html>