|
 |
asp_web_howto thread: List Box <SELECT> trim more than one spaces between characters to one space???
Message #1 by william.sze@s... on Wed, 23 Jan 2002 23:20:00 -0500
|
|
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
Message #2 by agaisin@c... on Thu, 24 Jan 2002 01:49:03 +0000
|
|
I don't know what your code looks like (you could post it) but, two things come to mind:
1) use server.urlencode for your querystrings (I believe multiple spaces may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and select...(either way, other difficult-to-track bugs may appear
if you're not using urlencode...)
2) something the select has that textarea doesn't is a value attribute - make sure that you're surrounding the content of the value
attribute with quotation marks (single or double) like so value='abc def' or value="abc def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -0500 ------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
Message #3 by william.sze@s... on Thu, 24 Jan 2002 10:41:14 -0500
|
|
Hi Arthur,
My code is as follow:
<%
strsql=select name from tblName
set rst=server.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=""T1"" cols=30 rows=10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=""T2"" rows=10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset but
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where to
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howto] Re: List Box <SELECT> trim more than one
PM spaces between characters to one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two things
come to mind:
1) use server.urlencode for your querystrings (I believe multiple spaces
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you're
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute -
make sure that you're surrounding the content of the value attribute with
quotation marks (single or double) like so value='abc def' or value="abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -0500
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #4 by agaisin@c... on Thu, 24 Jan 2002 11:03:26 +0000
|
|
Ok, I just played with a simple example and saw exactly what you described.
The solution is to use instead of whitespace.
simply replace " " with using the replace function like this:
response.write( replace(rst.Fields("failure_mode")," ", " ") )
That should do the job.
hth,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 10:41:14 -0500 ------
Hi Arthur,
My code is as follow:
<%
strsql=select name from tblName
set rst=server.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=""T1"" cols=30 rows=10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=""T2"" rows=10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset but
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where to
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howto] Re: List Box <SELECT> trim more than one
PM spaces between characters to one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two things
come to mind:
1) use server.urlencode for your querystrings (I believe multiple spaces
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you're
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute -
make sure that you're surrounding the content of the value attribute with
quotation marks (single or double) like so value='abc def' or value="abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -0500
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #5 by william.sze@s... on Thu, 24 Jan 2002 14:30:25 -0500
|
|
Arthur,
The replace function does the job to display all white spaces in selection
box. However, in my application it is still not working as I expected.
My application actually have a textbox above the selection box. User is
allowed to either type/scan in the failure_mode in the text box or select
the failure_mode from the selection box.
If user selected failure_mode from selection box, the text value of
selectIndex is then assigned as the text box value.
After using the replace function to substitute white spaces with ,
the data in both text box and selection box appear to be same as the
database data.
The application then submit the text box value(text value of selectedIndex)
to the next asp page, SaveFail.asp, after user press submit button.
In SaveFail.asp, I have SQL:
strSQL = "select * from tblName where failure_mode = '" & request
("txtFail") & "'"
which check whether the text box value has already existed in database or
not. If not, prompt error message. Under normal circumstances, recordset
can be created as the
request("txtFail") = text value of selectedIndex
With all white spaces already replaced by
I found that no recordset can be created from the above strSQL, no matter
what failure mode I selected except those without any white space in their
records in database.
However, I tried response.write the strSQL and paste it on Query Analyser,
it gives me a record. Surprisingly not from asp .
Then I reverse my code to troubleshoot again without the replacement of
white spaces with .
Now, recordset can be created from strSQL for most of the data in the
selection box except those with more than one spaces between two charaters.
Please help again?
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
01/24/2002 06:03 Subject: [asp_web_howto] Re: List Box <SELECT> trim more than one
AM spaces between characters to one space???
Please respond to
"ASP Web HowTo"
Ok, I just played with a simple example and saw exactly what you described.
The solution is to use instead of whitespace.
simply replace " " with using the replace function like this:
response.write( replace(rst.Fields("failure_mode")," ", " ") )
That should do the job.
hth,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 10:41:14 -0500
------
Hi Arthur,
My code is as follow:
<%
strsql=select name from tblName
set rst=server.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=""T1"" cols=30 rows=10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=""T2"" rows=10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset but
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where to
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howto]
Re: List Box <SELECT> trim more than one
PM spaces between characters to
one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two things
come to mind:
1) use server.urlencode for your querystrings (I believe multiple spaces
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you're
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute -
make sure that you're surrounding the content of the value attribute with
quotation marks (single or double) like so value='abc def' or value="abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -0500
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #6 by agaisin@c... on Thu, 24 Jan 2002 16:25:11 +0000
|
|
I think this should help...
write two simple utility functions - one to encode (i.e. replace whitespace with ) and one to unencode (i.e. replace
&nbps; with whitespace).
Before displaying this field (in the text boxes and the selects) call MyEncode
Then call MyUnEncode b/f saving it to db.
(write equivalent functions in javascript if necessary)
If I understand correctly this approach should simplify things...
Here are sample functions...
Function MyEncode(str)
MyEncode = replace(str," "," ")
End Function
Function MyUnEncode(str)
MyUnEncode = replace(str," "," ")
End Function
hope this helps,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 14:30:25 -0500 ------
Arthur,
The replace function does the job to display all white spaces in selection
box. However, in my application it is still not working as I expected.
My application actually have a textbox above the selection box. User is
allowed to either type/scan in the failure_mode in the text box or select
the failure_mode from the selection box.
If user selected failure_mode from selection box, the text value of
selectIndex is then assigned as the text box value.
After using the replace function to substitute white spaces with ,
the data in both text box and selection box appear to be same as the
database data.
The application then submit the text box value(text value of selectedIndex)
to the next asp page, SaveFail.asp, after user press submit button.
In SaveFail.asp, I have SQL:
strSQL = "select * from tblName where failure_mode = '" & request
("txtFail") & "'"
which check whether the text box value has already existed in database or
not. If not, prompt error message. Under normal circumstances, recordset
can be created as the
request("txtFail") = text value of selectedIndex
With all white spaces already replaced by
I found that no recordset can be created from the above strSQL, no matter
what failure mode I selected except those without any white space in their
records in database.
However, I tried response.write the strSQL and paste it on Query Analyser,
it gives me a record. Surprisingly not from asp .
Then I reverse my code to troubleshoot again without the replacement of
white spaces with .
Now, recordset can be created from strSQL for most of the data in the
selection box except those with more than one spaces between two charaters.
Please help again?
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo" <asp_web_howto@p...>
cc:
01/24/2002 06:03 Subject: [asp_web_howto] Re: List Box <SELECT> trim more than one
AM spaces between characters to one space???
Please respond to
"ASP Web HowTo"
Ok, I just played with a simple example and saw exactly what you described.
The solution is to use instead of whitespace.
simply replace " " with using the replace function like this:
response.write( replace(rst.Fields("failure_mode")," ", " ") )
That should do the job.
hth,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 10:41:14 -0500
------
Hi Arthur,
My code is as follow:
<%
strsql=select name from tblName
set rst=server.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=""T1"" cols=30 rows=10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=""T2"" rows=10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset but
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where to
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howto]
Re: List Box <SELECT> trim more than one
PM spaces between characters to
one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two things
come to mind:
1) use server.urlencode for your querystrings (I believe multiple spaces
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you're
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute -
make sure that you're surrounding the content of the value attribute with
quotation marks (single or double) like so value='abc def' or value="abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -0500
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears as
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #7 by william.sze@s... on Thu, 24 Jan 2002 17:23:08 -0500
|
|
Hi,
I didn't try to save the selectedIndex.text value to db. What my
application do is to check user input in text box matches with record i
n
db. If no match, user will be prompted with error message only.
I tried encode and then unecode before assigning value to text box in t
he
first asp page and then submit to SaveFail.asp. I check the querystring
,
all spaces become %A0 instead of the normal %. That is, "ABC DEF"
becomes "ABC%A0%A0%A0%A0DEF" in qstring.
I desperately tried:
replace(str, "A0", " ") or replace(str, "%A0", " ")
in SaveFail.asp and of course it still doesn't work.
Any hint?
agaisin@c...
online.com To: "ASP Web HowTo" <a
sp_web_howto@p...>
cc:
01/24/2002 11:25 Subject: [asp_web_howt
o] Re: List Box <SELECT> trim more than one
AM spaces between characters
to one space???
Please respond to
"ASP Web HowTo"
I think this should help...
write two simple utility functions - one to encode (i.e. replace whites
pace
with ) and one to unencode (i.e. replace &nbps; with whitespace).
Before displaying this field (in the text boxes and the selects) call
MyEncode
Then call MyUnEncode b/f saving it to db.
(write equivalent functions in javascript if necessary)
If I understand correctly this approach should simplify things...
Here are sample functions...
Function MyEncode(str)
MyEncode =3D replace(str," "," ")
End Function
Function MyUnEncode(str)
MyUnEncode =3D replace(str," "," ")
End Function
hope this helps,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 14:30:25 -05
00
------
Arthur,
The replace function does the job to display all white spaces in select
ion
box. However, in my application it is still not working as I expected.
My application actually have a textbox above the selection box. User is
allowed to either type/scan in the failure_mode in the text box or sele
ct
the failure_mode from the selection box.
If user selected failure_mode from selection box, the text value of
selectIndex is then assigned as the text box value.
After using the replace function to substitute white spaces with =A0 ,
the data in both text box and selection box appear to be same as the
database data.
The application then submit the text box value(text value of selectedIn
dex)
to the next asp page, SaveFail.asp, after user press submit button.
In SaveFail.asp, I have SQL:
strSQL =3D "select * from tblName where failure_mode =3D '" & request
("txtFail") & "'"
which check whether the text box value has already existed in database
or
not. If not, prompt error message. Under normal circumstances, recordse
t
can be created as the
request("txtFail") =3D text value of selectedIndex
With all white spaces already replaced by
I found that no recordset can be created from the above strSQL, no matt
er
what failure mode I selected except those without any white space in th
eir
records in database.
However, I tried response.write the strSQL and paste it on Query Analys
er,
it gives me a record. Surprisingly not from asp .
Then I reverse my code to troubleshoot again without the replacement of
white spaces with =A0.
Now, recordset can be created from strSQL for most of the data in the
selection box except those with more than one spaces between two charat
ers.
Please help again?
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/24/2002 06:03 Subject: [asp_web_howt
o]
Re: List Box <SELECT> trim more than one
AM spaces between characters
to
one space???
Please respond to
"ASP Web HowTo"
Ok, I just played with a simple example and saw exactly what you descri
bed.
The solution is to use =A0 instead of whitespace.
simply replace " " with =A0 using the replace function like this:
response.write( replace(rst.Fields("failure_mode")," ", "=A0") )
That should do the job.
hth,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 10:41:14 -05
00
------
Hi Arthur,
My code is as follow:
<%
strsql=3Dselect name from tblName
set rst=3Dserver.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=3D""T1"" cols=3D30 rows=3D10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=3D""T2"" rows=3D10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset bu
t
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where t
o
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howt
o]
Re: List Box <SELECT> trim more than one
PM spaces between characters
to
one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two thi
ngs
come to mind:
1) use server.urlencode for your querystrings (I believe multiple space
s
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you'r
e
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute
-
make sure that you're surrounding the content of the value attribute wi
th
quotation marks (single or double) like so value=3D'abc def' or valu
e=3D"abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -05
00
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and
D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears a
s
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the
asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces
as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #8 by william.sze@s... on Thu, 24 Jan 2002 18:53:15 -0500
|
|
Well, decided to work around it by javascript to assign text box value
directly from array previously created for faliure_mode list.
But still quite do understand why it does not work for selectedIndex
textvalue and why selection box shrinks extra white spaces?
Thanks
William
William Sze
To: "ASP Web HowTo" <asp_w
eb_howto@p...>
01/24/2002 cc:
05:23 PM Subject: Re: [asp_web_howt
o] Re: List Box <SELECT> trim more than one
spaces between characters to o
ne space???(Document link: William Sze)
Hi,
I didn't try to save the selectedIndex.text value to db. What my
application do is to check user input in text box matches with record i
n
db. If no match, user will be prompted with error message only.
I tried encode and then unecode before assigning value to text box in t
he
first asp page and then submit to SaveFail.asp. I check the querystring
,
all spaces become %A0 instead of the normal %. That is, "ABC DEF"
becomes "ABC%A0%A0%A0%A0DEF" in qstring.
I desperately tried:
replace(str, "A0", " ") or replace(str, "%A0", " ")
in SaveFail.asp and of course it still doesn't work.
Any hint?
agaisin@c...
online.com To: "ASP Web HowTo" <a
sp_web_howto@p...>
cc:
01/24/2002 11:25 Subject: [asp_web_howt
o] Re: List Box <SELECT> trim more than one
AM spaces between characters
to one space???
Please respond to
"ASP Web HowTo"
I think this should help...
write two simple utility functions - one to encode (i.e. replace whites
pace
with ) and one to unencode (i.e. replace &nbps; with whitespace).
Before displaying this field (in the text boxes and the selects) call
MyEncode
Then call MyUnEncode b/f saving it to db.
(write equivalent functions in javascript if necessary)
If I understand correctly this approach should simplify things...
Here are sample functions...
Function MyEncode(str)
MyEncode =3D replace(str," "," ")
End Function
Function MyUnEncode(str)
MyUnEncode =3D replace(str," "," ")
End Function
hope this helps,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 14:30:25 -05
00
------
Arthur,
The replace function does the job to display all white spaces in select
ion
box. However, in my application it is still not working as I expected.
My application actually have a textbox above the selection box. User is
allowed to either type/scan in the failure_mode in the text box or sele
ct
the failure_mode from the selection box.
If user selected failure_mode from selection box, the text value of
selectIndex is then assigned as the text box value.
After using the replace function to substitute white spaces with =A0 ,
the data in both text box and selection box appear to be same as the
database data.
The application then submit the text box value(text value of selectedIn
dex)
to the next asp page, SaveFail.asp, after user press submit button.
In SaveFail.asp, I have SQL:
strSQL =3D "select * from tblName where failure_mode =3D '" & request
("txtFail") & "'"
which check whether the text box value has already existed in database
or
not. If not, prompt error message. Under normal circumstances, recordse
t
can be created as the
request("txtFail") =3D text value of selectedIndex
With all white spaces already replaced by
I found that no recordset can be created from the above strSQL, no matt
er
what failure mode I selected except those without any white space in th
eir
records in database.
However, I tried response.write the strSQL and paste it on Query Analys
er,
it gives me a record. Surprisingly not from asp .
Then I reverse my code to troubleshoot again without the replacement of
white spaces with =A0.
Now, recordset can be created from strSQL for most of the data in the
selection box except those with more than one spaces between two charat
ers.
Please help again?
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/24/2002 06:03 Subject: [asp_web_howt
o]
Re: List Box <SELECT> trim more than one
AM spaces between characters
to
one space???
Please respond to
"ASP Web HowTo"
Ok, I just played with a simple example and saw exactly what you descri
bed.
The solution is to use =A0 instead of whitespace.
simply replace " " with =A0 using the replace function like this:
response.write( replace(rst.Fields("failure_mode")," ", "=A0") )
That should do the job.
hth,
Arthur Gaisin
---- Message from william.sze@s... at Thu, 24 Jan 2002 10:41:14 -05
00
------
Hi Arthur,
My code is as follow:
<%
strsql=3Dselect name from tblName
set rst=3Dserver.CreateObject("ADODB.Recordset")
rst.open strsql, oCnn, adoOpenDynamic, adoLockOptimistic
response.write "<textarea name=3D""T1"" cols=3D30 rows=3D10 readonly>"
while not rst.EOF
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</textarea>"
rst.MoveFirst
response.write "<select name=3D""T2"" rows=3D10>"
while not rst.EOF
response.write "<option>"
Response.Write(rst.Fields("failure_mode"))
Response.Write(chr(13))
rst.MoveNext
wend
response.write "</select>
%>
Both textarea and selection box are on the same page, same recordset bu
t
different result:
The textarea gives record same as database: "ABC DEF" , while
the select box gives data different fm database: "ABC DEF"
There is not querystring involvement in here and I have no idea where t
o
put the single quote as you mentioned.
Please advise.
Thanks
William
agaisin@c...
online.com To: "ASP Web HowTo"
<asp_web_howto@p...>
cc:
01/23/2002 08:49 Subject: [asp_web_howt
o]
Re: List Box <SELECT> trim more than one
PM spaces between characters
to
one space???
Please respond to
"ASP Web HowTo"
I don't know what your code looks like (you could post it) but, two thi
ngs
come to mind:
1) use server.urlencode for your querystrings (I believe multiple space
s
may b/c a single space without encoding)
but that doesn't necessarily explain the discrepency b/w textarea and
select...(either way, other difficult-to-track bugs may appear if you'r
e
not using urlencode...)
2) something the select has that textarea doesn't is a value attribute
-
make sure that you're surrounding the content of the value attribute wi
th
quotation marks (single or double) like so value=3D'abc def' or valu
e=3D"abc
def"
This may also be the cause of your troubles...
hth - please let us know.
Arthur Gaisin
---- Message from william.sze@s... at Wed, 23 Jan 2002 23:20:00 -05
00
------
Hi all,
I have a record of string , "ABC DEF", (note: 4 spaces between C and
D)
in my database.
When I display the record in <TEXTAREA> it shows "ABC DEF", (note: 4
spaces between C and D), same as record in database.
However, when I display the record in a list box <SELECT>, it appears a
s
"ABC DEF", (note: only 1 space between C and D)
So when I check the text value of select box with database record, the
asp
cannot find the match.
Is it a charateristics of <SELECT> ? Can I avoid the trimming of spaces
as
above.?
Please help.
Thanks
William
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
$subst('Email.Unsub').
|
|
 |