Need help fast! <------- (come on, all coders)

VoodooExtreme

Golden Member
Jan 25, 2000
1,907
0
71
I've got this problem... I'm getting data from a database and getting it into an textbox but instead of getting &quot;<br>&quot; in the textbox I wanna convert it so it shows as ENTER marks instead (you know when you press the ENTER button and you get a new line to write on)...

anyway to do this?

(I know there is.. but I can't figure it out... :( )
 

Kosugi

Senior member
Jan 9, 2001
457
0
0
Voodoo, use a little java script. At the end of each line returned from your database, append by the javascript '+' operator, a '\n'. That simulates a newline. I can dig around for an example...
 

Pretender

Banned
Mar 14, 2000
7,192
0
0
You could use substr(data, &quot;<BR>&quot;), it'll give you the position of the first instance of <BR> in the data, then you can replace it with \n.

The problem is, \n is only one byte, but <BR> is 4, so you'd need to either fill the other 3 with something, or shift everything to the right of it over to the left 3 places.
 

VoodooExtreme

Golden Member
Jan 25, 2000
1,907
0
71
I've got this script to convert it to other way...

<script language=&quot;JavaScript&quot;>
<!--
function test(theForm){
makeBreak(theForm);
return true;
}

//replaces newlines with <br>
function makeBreak(theForm){
var newLinePat = /\r\n/g;
theStr = theForm.vdMsg.value;
theStr = theStr.replace(newLinePat, &quot;<br>&quot;);
theForm.vdMsg.value = theStr
}

//-->
</script>

Anyone know can help me rewrite this script the other way around... (I'm not the programmer where I work, and he's free today... So, I'd be glad if anyone can help.

Thanx in advance!
/Stefan