Solved

apostrophes in list box(' /")

Posted on 2002-03-07
6
209 Views
Last Modified: 2008-03-17
I am having problem when comparing the values i requested from a list box which display data from the database.

e.g:

machine =Request.form("selMachine")

<option VALUE ='<%=rs("MACHINE")%>' <%if trim(rsAccessory("MACHINE"))=machine then Response.Write "selected" end if%>><%=rs("MACHINEACCESSORIES")%>
</option>

so if i selected a value from the list box which contained ("), it won't be selected.
0
Comment
Question by:green_tea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:dovholuk
ID: 6849577
apostrophes are a particular problem as they can be used as string delimeters. the best thing to try is instead of using apostrophes ( chr(39) ) in your option statement, use quotes instead ( chr(34) ). such as:
<option VALUE =<%=chr(34) & rs("MACHINE") & chr(34)%>

make sense?

that should fix the issue. if not, let us know...

dovholuk
0
 

Author Comment

by:green_tea
ID: 6849709

machine =Request.form("selMachine")

<option VALUE ='<%=rs("MACHINE")%>' <%if trim(r("MACHINE"))=machine then Response.Write "selected"
end if%>><%=rs("MACHINE")%>
</option>

The value in rs("MACHINE") contained double quotes(") or single quotes(').

for example the value display in list box (from database)
is :Edge Guide (1/4")

-if i don't put <option VALUE ='<%=rs("MACHINE")%>'>
(take note of the single quote)
i will get Edge Guide (1/4 instead of  Edge Guide (1/4")
-with the single quote <option VALUE ='<%=rs("MACHINE")%>'>
i can get Edge Guide (1/4") but when execute the following
<%if trim(rsAccessory("MACHINE"))=machine then Response.Write "selected"
it seems cannot find the right one.
-i suspect the "/'

please help


0
 
LVL 54

Expert Comment

by:nico5038
ID: 6849852
Using special characters like ' and " in strings, the effects normally can be "neutralized" by placing twice the same character iso one.

Nic;o)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:DanielBlais
ID: 6850402
I have corrected the problem like this :

<INPUT TYPE="text" NAME="sTitre" SIZE="40" MAXLENGTH="50" VALUE=<%
delim = chr(34)
if instr(titre, "'") = 0 and instr(titre, chr(34)) > 0 then delim = "'"
response.write delim & cstr(titre) & delim
%>>


What it does, it replace " by ' when the string containt ".  This as an limitation, when the string containt " and '.

0
 
LVL 54

Expert Comment

by:nico5038
ID: 7049535
for green_tea

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 7070200
moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question