Results 1 to 6 of 6

Thread: Help with reading HTML code from a database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    UK
    Posts
    204

    Question Help with reading HTML code from a database

    I have an access database that contains HTML code, this code is read into a textarea object that is on my page, however if this code in the database contains for example "& q u o t;" it gets converted into its appropriate HTML syntax when its read into the textarea, and then when the user clicks "Update" the database is updated with the wrong information, how can I prevent this from happening?

    This is very hard to explain so please say if you dont understand...
    Last edited by Neilbaker86; Apr 1st, 2003 at 06:41 PM.

  2. #2
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    use Replace() function to avoid this problem
    Code:
    strData=replace(request.form("YourTextAreaName"),""", """)
    see what i mean

  3. #3
    Lively Member
    Join Date
    Nov 2001
    Location
    Behind you...
    Posts
    88
    On that note, I would like to add a question...

    What if you have a MS database that contains a Memo datatype with HTML syntax in it ie <br> and you want to load that into a textarea. It shouldn't be converted into &quot; (or whatever the syntax is for < and >, I can't remember).
    The text in the database should be loaded into a textarea exactly as it is written in the database!!
    Enjoy...
    ----
    If something is hard to do then it aint worth doing!!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    UK
    Posts
    204
    Yeh, a <br> would still be in text form but if you have the code way to display the "code" like the "& l t ;" it gets converted to its appropriate symbol when its loaded into the textarea. which i want it to stay as "& l t ;".
    Last edited by Neilbaker86; Apr 2nd, 2003 at 05:42 AM.

  5. #5
    Hyperactive Member Anglo Saxon's Avatar
    Join Date
    Mar 2002
    Location
    Durham, UK
    Posts
    259
    Use server.HTMLEncode :
    Code:
    <textarea cols="35" rows="10">
    <%
    Response.Write "&lt;a href=&qu ot;page.asp&qu ot;&gt;click&lt;/a&gt;" & vbCrLf
    Response.Write server.htmlencode("&lt;a href=&qu ot;page.asp&qu ot;&gt;click&lt;/a&gt;")
    %>
    </textarea>
    remember to remove the [spaces] out of the &qu ot; in the examples above!
    ---

    Anglo Saxon

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    UK
    Posts
    204

    Cool Cheers!

    Thanks Anglo Saxon it works a treat now!

Posting Permissions

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



Click Here to Expand Forum to Full Width