How to avoid space trimming in HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Matsam
    New Member
    • Jun 2007
    • 33

    How to avoid space trimming in HTML

    Hi,

    I have a search page in which I take data from a recordset. Some data which is retrieved may have more than one space between 2 words. But in my result page, HTML is truncating those spaces into single space and displays the result. But I need it as it is in the database. Is there any way similar to &nbsp which can be applied to this situation? My code is as follows:

    <TD nowrap borderColor=mar oon width="180"><FO NT size=3><%=rs(0) %></FONT></TD>
    in which rs(0) is the field containing spaces.

    Plz help me..

    Thanks in advance

    Matsam
  • nedu
    New Member
    • Nov 2006
    • 65

    #2
    Hi,

    You shall use the following code to allow spaces while accessing the DB.

    Response.Write "<PRE><font face=monospace size=10>" & Rs.Fields(0) & "</font></PRE>"

    Let me know for any other queries . . .

    Regards,
    Nedu. M

    Comment

    • Matsam
      New Member
      • Jun 2007
      • 33

      #3
      Originally posted by nedu
      Hi,

      You shall use the following code to allow spaces while accessing the DB.

      Response.Write "<PRE><font face=monospace size=10>" & Rs.Fields(0) & "</font></PRE>"

      Let me know for any other queries . . .

      Regards,
      Nedu. M

      Hi,

      Thanks for your help. But I'm sorry, my problem still remains open...
      Actually I want to take records from a table and populate it into a combo box. The <PRE> tag is not working in this case.. Other situations it is ok. Following is my code:

      <SELECT id=select4 style="WIDTH: 256px; HEIGHT: 22px"
      name=lstSubject >
      <% do while not rs3.EOF %>
      <OPTION > <PRE> <%=rs3(0) %> </PRE> </OPTION>

      <% rs3.MoveNext
      loop
      rs3.close %>

      </SELECT>

      where rs3 is my recordset.

      Here nothing happens on including <PRE> tag.

      Pls help..

      Thanks again

      Matsam

      Comment

      • nedu
        New Member
        • Nov 2006
        • 65

        #4
        Hi Mastam,

        Use the following code

        <Select>
        <%
        While Not Rs.EOF
        Txt = Replace(rs.Fiel ds(0)," ", "&nbsp;")

        %>
        <option value="<%=Txt%> "><%= Txt %></option>
        <%
        Rs.MoveNext
        wend
        %>

        </Select>

        Let me know for any other queries.

        Regards,
        Nedu . M

        Comment

        • Matsam
          New Member
          • Jun 2007
          • 33

          #5
          Originally posted by nedu
          Hi Mastam,

          Use the following code

          <Select>
          <%
          While Not Rs.EOF
          Txt = Replace(rs.Fiel ds(0)," ", "&nbsp;")

          %>
          <option value="<%=Txt%> "><%= Txt %></option>
          <%
          Rs.MoveNext
          wend
          %>

          </Select>

          Let me know for any other queries.

          Regards,
          Nedu . M
          Hi Nedu,

          Thanks a lot for ur help. Now my problem is solved.
          Thanks again...

          Regards
          Matsam

          Comment

          Working...