A problem with "quotes" in my text field

Experts,

I've got to put a page together that allows the user to edit some descriptions. All is well until one of those descriptions includes a quote. For example 12" table. When that particular item is listed, all that shows up in the text field is "12".

The reason being is that the text field script looks like this...

<input type="text" size="45" name="Description" value="<% response.write RSResult("Description") %>">

As soon as the browser encounters the value where it reads 12" it perceives the quote after 12 as the end of the value. What can I do to ensure that the entire description (12" Conference Table) as opposed to a mere fragment (12) is displayed in my text field?
brucegustPHP DeveloperAsked:
Who is Participating?
 
_iskywalker_Commented:
<input type="text" size="45" name="Description" value="<% response.write RSResult("Description") %>">
you have a strange field here:
 value="<% response.write RSResult("Description") %>">
i think a normal browser would parse like this:
value="<% response.write RSResult("
better would be if you change the out " for ' like
 value='<% response.write RSResult("Description") %>'>
maybe it works then, but if not see the comments above, since if you one " the next " will close the "input"
0
 
nonubikCommented:
You need to parse all the " and replace them with %22
0
 
nonubikCommented:
E.g.: 12%22 Conference Table
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
softplusCommented:
or another way:
<input type="text" size="45" name="Description" value="<% replace(response.write RSResult("Description"),"""", "%22") %>">

jskywalker: The single-quote doesn't matter, it's ASP-Code, i.e. interpreted on the server, not on the browser.

John
0
 
CyberSwineCommented:
I believe you will have a similar problems with the % character as well. If I remember this right you should replace "%" with "%%". Replacing """" with "%22" would have to be done afterward, or the "%22" would become "%%22", which will look like %22, not a doublequote char. So, modifying softplus' example to include this yields:

<input type="text" size="45" name="Description" value="<% replace(replace(response.write RSResult("Description"), "%", "%%"),"""", "%22") %>">

0
 
softplusCommented:
Looking at my comment, I should hit my head , sorry :)
<input type="text" size="45" name="Description" value="<%=replace(RSResult("Description"),"""", "%22") %>">
or CyberSwines
<input type="text" size="45" name="Description" value="<%=replace(replace(RSResult("Description"), "%", "%%"),"""", "%22") %>">

he he, putting Replace around Response.Write ...
0
 
CyberSwineCommented:
You and me both. Sometimes I just don't pay attention to the actual code :D
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.