Print Page | Close Window

<textarea> and single quotes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10813
Printed Date: 28 March 2026 at 1:10am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: <textarea> and single quotes
Posted By: fatcity101
Subject: <textarea> and single quotes
Date Posted: 10 June 2004 at 10:22am

Hello all,

I have an ASP page with a <textarea> on it that is posting the contents of the <textarea> into an Access database. When the form on the page is processed, the following code is used before putting the information into the database:

var mytextarea = Request("mytextarea")+"";

mytextarea = mytextarea.replace("'", "''");

This is supposed to deal with the single quotes before the INSERT query The problem is that it only works if mytextarea has one quote. If there are more than one quote in mytextarea, I receive the following error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Isn''t it funny this doesn't work'

Anyone know how to replace multiple instances of single quotes?

Thanks in advance




Replies:
Posted By: dj air
Date Posted: 11 June 2004 at 2:01pm

use this example

mytextArea = Replace(mytextArea , "value you want to change", "value you want to change it to", 1, -1, 1)

you can leave the second "" like "" which will replace the other value to nothing. resulting in deleting the value.

hope that helps



Posted By: Semikolon
Date Posted: 12 June 2004 at 5:13pm
Replace(myTextArea, "'", "&#39;")

this will replace the single quote ' with &#39; which will display as '


Posted By: Bluefrog
Date Posted: 14 June 2004 at 11:50am

It's amazing how many encodings can't keep basic standards. The web is a mess.

Someday we'll have something that actually works.

(I'm referring to how different encodings slaughter the single and double quote characters.)



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net