Click to See Complete Forum and Search --> : print line by line in Text Area


raghu123
09-29-2006, 07:52 AM
what is the value i need to replace for <cr> to make break the lines and show in Text Area.


Example
Lieude l'incident - Location of Incident<cr>111111111<cr>Expliquez ce qui s'est passé - Explain what happened<cr>2222222222<cr>Conséquences potentielles - Potential Consequences<cr>333333333<cr>

Expected Result in Text ARea

Lieude l'incident - Location of Incident
111111111
Expliquez ce qui s'est passé - Explain what happened
2222222222
Conséquences potentielles - Potential Consequences
333333333

Mr J
09-29-2006, 09:12 AM
Here's one possibility

<textarea id="t1" style="width:600px;height:200px;"></textarea>

<script type="text/javascript">

str="Lieude l'incident - Location of Incident<cr>111111111<cr>Expliquez ce qui s'est passé - Explain what happened<cr>2222222222<cr>Conséquences potentielles - Potential Consequences<cr>333333333<cr>"

str=str.replace(/<cr>/gi,"\n")

document.getElementById("t1").value=str

</script>

raghu123
10-03-2006, 02:28 AM
Mr J,

What is meaning of
/<cr>/gi

in
str=str.replace(/<cr>/gi,"\n")

sridhar_423
10-03-2006, 02:36 AM
replaces all occurences("g") of "<cr>" with "\n" and case-insensitive("-i")