Solved

apostrophes in list box(' /")

Posted on 2002-03-07
6
210 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

728 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