Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing line breaks with <br>

Status
Not open for further replies.

emms

Programmer
Jan 11, 2001
55
0
0
GB
I'm sure this is an easy one but it's driving me mad.

I'm using Jscript and have tried:

Headline = replace(Request.Form(&quot;Headline&quot;), vbCr, &quot;<br>&quot;);
Headline = replace(Request.Form(&quot;Headline &quot;), lr, &quot;<br>&quot;);
Headline = Replace(Request.Form(&quot;Headline &quot;), Chr(13), &quot;<br>&quot;);

all return an error:

'vbCr' is undefined
'lr' is undefined
Object expected


any help would be hugely appreciated!

thanks

Emma
 
You need to use this to represent the line break:

Code:
String.fromCharCode(13)

Having said that, I don't think you can use the Replace function in JavaScript like that. I'm still checking what the equivalent is...

--James
 
Actually, have a look at this. I forgot about the \n for a new line:

Code:
<%
myString = &quot;Line 1\nLine 2&quot;

Response.Write(&quot;<p>&quot; + myString + &quot;</p>&quot;)

rExp = /\n/gi;
results = myString.replace(rExp, &quot;<br />&quot;)

Response.Write(results)
%>

--James
 
Headline = replace(Request.Form(&quot;Headline&quot;), vbCrLf, &quot;<br>&quot;);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top