PDA

View Full Version : I need Linebreaks?? textarea.value using javascript, then assign to td.textContent



dorisf
23 Mar 2010, 06:18 PM
I am desparate for some help - worked all day on this silly little problem:


Wanted:
======
To read the typed in text in a textarea using javascript - with both IE and Firefox,
then to stuff that value into a table's td, or a label.

The end result is the TD should retain the linebreaks that were entered in the textarea.

This works fine in IE but not in Firefox - and after browing the net all day - I cant seem to find an answer.

Is there an answer? Please help me someone.

My Kindest Regards,

Doris.


MY SAMPLE CODE
============================
HTML
++++++++++
<textarea name="text" id="text2" cols="45" rows="8"></textarea>

<div onclick="javascript:Here();">click here</div>

<table runat="server" ID="id"><tr><td runat="server" ID="id">dsadsadaa</td></tr></table>

JAVASCRIPT
++++++++++
objTDClientID = document.getElementById("id1");
var ss = document.getElementById('text2').value;
ss = ss.replace(/(\r\n)|(\n)/g, "<br />");




if (objTDClientID.textContent) {
objTDClientID.textContent = objTextArea.value;
}
else {
objTDClientID.innerHTML = ss;
}

is_numeric
24 Mar 2010, 02:37 AM
view the source and see if the <br /> is being output