A problem with "quotes" in my text field


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?
<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"
You need to parse all the " and replace them with %22
E.g.: 12%22 Conference Table
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.

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.

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") %>">

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 ...
You and me both. Sometimes I just don't pay attention to the actual code :D
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.