?
Solved

apostrophes in list box(' /")

Posted on 2002-03-07
6
Medium Priority
?
213 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
Technology Partners: 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

649 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