2

How can I change "spaces" on records being returned by a recordset?

For example, I have this code that will return a value of "John Doe":

<td width="30%"><%=rsTmp("Name")%></font></td>

What I would like to do is to change the space between the words into:

&nbsp;

so that when my page got congested the name "John Doe" will still be in a straight line, and will not be separated?

peterh
  • 11,875
  • 18
  • 85
  • 108
zerey
  • 871
  • 11
  • 19
  • 37

3 Answers3

3

I resolved it! I used replace function like this.

<% Replace(rsTmp("Name")," ","&nbsp;")%>
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
zerey
  • 871
  • 11
  • 19
  • 37
3

In Classic ASP you will need to code the following:

<%= Replace(rsTmp("Name")," ","&nbsp;") %>

Which is the same as

<%
    Response.Write ( Replace(rsTmp("Name")," ","&nbsp;") )
%>
Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84
3

Actually, I would suggest using replace(rsTmp("Name"), " ", "&#160;")

In HTML5 the ASCII code &nbsp; are replaced with &#160;. You might as well do this from this day and onwards ;)

MicBehrens
  • 1,780
  • 8
  • 34
  • 57