Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe and input box

Status
Not open for further replies.

MnM

Programmer
Nov 1, 2000
47
US
I have a recordset that I loop through to get all of the comments out of the database and into an input box to display on the screen. The problem is if there is an apostrophe in the comment it cuts the comment off. I was wondering how I go about fixing this. It prints the comment out fine if it's not in the input box but they need to be in input boxes so they can be editied. The problem spot of my code is as follows:

Code:
do until rs2.eof
	comment = rs2("comment")
	response.write &quot;<td><input type=&quot;&quot;text&quot;&quot; name=&quot;&quot;comments&quot;&quot; value='&quot;&comment&&quot;'><br>&quot;
	rs2.movenext
loop

An example of different output would be:
Hello World would show up as Hello World
Hello's World would show up as Hello

Please Help. Thanks!
 
What I do to get round this problem is to replace the apostrophe with the HTML entity which is & #39; (without the space between the & and #) I usually do it as the data is going in to the database rather than out of it as you are suggesting - but it should still work this way.

Code should be something like:

Code:
dim strComment
strComment = rs2(&quot;comment&quot;)
strComment = Replace(strComment, &quot;'&quot;, &quot;& #39&quot;)
Response.Write &quot;<input type='text' value='&quot;& strComment &&quot;'>&quot;
 
you wouldnt have this problem if you wrapped the value in double quotes:

do until rs2.eof
comment = rs2(&quot;comment&quot;)
response.write &quot;<td><input type=&quot;&quot;text&quot;&quot; name=&quot;&quot;comments&quot;&quot; value=&quot;&quot;&quot;&comment&&quot;&quot;&quot;><br>&quot;
rs2.movenext
loop

 
BeckD Thanks that worked perfectly!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top