Solved

apostrophes in list box(' /")

Posted on 2002-03-07
6
204 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
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now