www.webdeveloper.com
Results 1 to 2 of 2

Thread: Saving textarea and display like HTML

  1. #1
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    53

    Saving textarea and display like HTML

    Hi, guys.
    I have question again.
    Please take a look at code.
    Code:
    <HTML>
    <HEAD>
    </HEAD>
    <BODY LEFTMARGIN=0 MARGINWIDTH="0" MARGINHEIGHT="0">
    <form name="frmAdd" method="post" action="updateMSI.asp?state=add" onsubmit="return add();">
    <table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
    	<tr>
    	  <td class="row1" valign="top"><span class="gen"><b>Content</b></span></td>
    	  <td class="row2" valign="top"><span class="gen"> <span class="genmed"><textarea type="text" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3" name="content"></textarea></span></td>
    	</tr>
    	<tr>
    	  <td class="catBottom" colspan="2" align="center" height="28"><input type="submit" name="Submit" value="Submit"></td>
    	</tr>
    </table>
    		</form>
    </BODY>
    </HTML>
    As you can see, when I type following text in text area
    Hi Team:

    This morning we released our financial results for the third quarter of 2003 (please see attached News Release or check out the Wins Bulletin Board on each of your floors).

    Last quarter we discussed going for a ˇ°three-peatˇ± and we are pleased to announce that we did it!
    And click submit and it saves on the database alright.
    But problem is when I get this text from databse to display on following page.

    Code:
    <html>
    <head>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <%
    dim todaysDate
    Dim adoCon 			'Holds the Database Connection Object
    Dim rsGuestbook			'Holds the recordset for the records in the database
    Dim strSQL			'Holds the SQL query for the database
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
    Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
    num=Request.QueryString("ID")
    
    strSQL = "SELECT * FROM tblMSI WHERE ID =" & num 
    rsGuestbook.Open strSQL, adoCon
    todaysDate=rsGuestbook("Date")
    %>
    <table width="90%" border="1" bordercolor="#666666" align="center" cellpadding=20>
    <tr>
        <td bgcolor="#CCCCCC" height="300" bordercolor="#666666"> 
              <% Response.Write (rsGuestbook("Content")) %>  
         </td>
      </tr>
    </table>
    <%
    'Reset server objects
    rsGuestbook.Close
    Set rsGuestbook = Nothing
    Set adoCon = Nothing
    %>
    </body>
    </html>
    Text appears like this!
    Hi Team: This morning we released our financial results for the third quarter of 2003 (please see attached News Release or check out the Wins Bulletin Board on each of your floors).
    How can I make it display like same as when I entered it?
    Just like this forum.

  2. #2
    Join Date
    Nov 2003
    Posts
    22
    What you have to do is go through the textarea text before you upload it and replace Carriage returns with "<br />

    A=CStr(request("content"))
    B=""

    for n=1 to len(A)
    if mid(A,n,1)=chr(13) or mid(A,n,1)=chr(10) then
    if mid(A,n,1)=chr(13) then B=B & "<br />"
    else
    B=B & mid(A,n,1)
    end if
    next

    That code should stick your re-formatted text in a str called B. Upload B to your database and bobs your uncle.

    I suggest also getting rid of the textarea property "WRAP=VIRTUAL".

    Last edited by GlennCarter; 11-27-2003 at 07:15 AM.
    Glenn Carter

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles