PDA

View Full Version : Replace Page Breaks


gojita
01-27-2003, 08:52 PM
I want to know if there is a way to replace page breaks (caused by pressing Enter/Return in a text feild) with <br> or something else.
Thanks for your help!

cg9com
01-27-2003, 08:54 PM
\n , works in javascript
you could use css to conserve white space

gojita
01-27-2003, 08:56 PM
How would you do that?

cg9com
01-27-2003, 09:00 PM
whats a text box? textarea? im pretty sure they preserve the spaces
<textarea></textarea>

<script type="text/javascript">
alert('line1\nline2');
</script>

rsci
01-27-2003, 10:11 PM
Are you wanting to take the text entered into textarea and replace the instances when a user has pressed return with <br> code?

whammy
01-27-2003, 11:57 PM
Are you perhaps pulling this from a database using server-side scripting?

gojita
01-28-2003, 01:50 AM
Originally posted by rsci
Are you wanting to take the text entered into textarea and replace the instances when a user has pressed return with <br> code?

Yeah, this is what I wanted.
If you know how, I would really appreciate it!

glenngv
01-28-2003, 06:37 AM
str=document.formNameHere.textareaNameHere.value.replace(/\n/g,'<br />');
alert(str)

gojita
01-28-2003, 10:32 AM
Thanks!