Forum Moderators: open

Message Too Old, No Replies

%20

         

stevelibby

8:28 am on Apr 13, 2006 (gmt 0)

10+ Year Member



When i display results from a database using front page wizard spaces are returned with '%20' how can i remove the spaces?

celgins

1:07 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you referring to spaces in a URL querystring?

stevelibby

2:38 pm on Apr 13, 2006 (gmt 0)

10+ Year Member



Yes, the data entry is Alfa Romeo, but is being shown back as Alfa%20Romeo, if i use hard coded asp code then it showns as normal, but using frontpage it shows as Alfa%20Romeo, what can i do to change it

celgins

5:21 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, I'm not sure how to do it for Frontpage, but you'll probably need to use one of the decoding functions like:

<%

Private Function URLDecode(byVal encodedstring)
Dim strIn, strOut, intPos, strLeft
Dim strRight, intLoop

strIn = encodedstring : strOut = _
"" : intPos = Instr(strIn, "+")

Do While intPos
strLeft = "" : strRight = ""
If intPos > 1 then _
strLeft = Left(strIn, intPos - 1)
If intPos < len(strIn) then _
strRight = Mid(strIn, intPos + 1)
strIn = strLeft & " " & strRight
intPos = InStr(strIn, "+")
intLoop = intLoop + 1
Loop

intPos = InStr(strIn, "%")

Do while intPos
If intPos > 1 then _
strOut = strOut & _
Left(strIn, intPos - 1)
strOut = strOut & _
Chr(CInt("&H" & _
mid(strIn, intPos + 1, 2)))

If intPos > (len(strIn) - 3) then
strIn = ""
Else
strIn = Mid(strIn, intPos + 3)
End If

intPos = InStr(strIn, "%")
Loop

URLDecode = strOut & strIn
End Function

mystring = URLDecode("myfile.asp?myid=1&myname=John%20Harry%20Doe")

%>

Which will return:

"myfile.asp?myid=1&myname=John Harry Doe"