green_tea
asked on
apostrophes in list box(' /")
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("MACHINEACCESSO RIES")%>
</option>
so if i selected a value from the list box which contained ("), it won't be selected.
e.g:
machine =Request.form("selMachine"
<option VALUE ='<%=rs("MACHINE")%>' <%if trim(rsAccessory("MACHINE"
</option>
so if i selected a value from the list box which contained ("), it won't be selected.
ASKER
machine =Request.form("selMachine"
<option VALUE ='<%=rs("MACHINE")%>' <%if trim(r("MACHINE"))=machine
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"
it seems cannot find the right one.
-i suspect the "/'
please help
Using special characters like ' and " in strings, the effects normally can be "neutralized" by placing twice the same character iso one.
Nic;o)
Nic;o)
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 '.
<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 '.
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)
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<option VALUE =<%=chr(34) & rs("MACHINE") & chr(34)%>
make sense?
that should fix the issue. if not, let us know...
dovholuk