?
Solved

apostrophes in list box(' /")

Posted on 2002-03-07
6
Medium Priority
?
211 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

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…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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 …
Suggested Courses

764 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