Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Space in Variable String

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I am submitting a variable to a script something like this:
Code:
<A HREF=&quot;script.asp?DatabaseVariable=<%Response.Write DoVar(rs(&quot;DatabaseVariable&quot;))%>&quot;>Same Variable Here</a>

It works just fine in Internet Explorer and in Netscape 6.0, but Netscape 4.X has issues with the fact that the DatabaseVariable has spaces. If I do it from a conventional form, it works fine but that is not a desirable way of doing it. I've tried forcing both single and double quotes around the string, but that crashes the script to which it is being submitting. Removing the spaces from the database field itself is not an option. What else can I try?

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Thanks. How is that done?

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
i think its Server.urlencode(varname)

atleast that's how its done in jscript.

most likely for vbscript its Server.urlencode varname adam@aauser.com
 
Not being a programmer, I was not able to figure out what to do with Server.urlencode. I did find here in the ASP forum, a JavaScript that will submit a form from a text hyperlink, but it has &quot;issues&quot; too! I would prefer not doing it with JavaScript anyway. Does anyone have any other ideas, or can someone give more details on Server.urlencode? Thanks!

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
its like this:

variable = Server.urlencode somevariable

somevariable is what you want encoded, and variable is the return value. you will then use variable as the encoded variable.

you can use the same variable name for both. ex:

qu = Server.erlencode qu

adam@aauser.com
 
To use your example:

<A HREF=&quot;script.asp?DatabaseVariable=<%=Server.URLEncode(DoVar(rs(&quot;DatabaseVariable&quot;)))%>&quot;>Same Variable Here</a>



Wushutwist


Sun Certified Java 2 Programmer
 
Ah, that makes more sense! I was trying to put it on the receiving page rather than the sending one. Does the receiving page need anything special too? Doing it per your example, it works just exactly like it did without it, which doesn't make sense to me. I would think that it should at least have given an error, but it didn't.

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
My simplified example showed only one value being passed on. Actually there are several, but only the one is causing a problem. Some are hard-coded, while others are variables coming from the database. The rest do not have spaces in them. But could that be the reason it continues to not work?

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Got it! What I had to do was to redeclare the value and put it into a new, simpler variable where there was only one set of quotes with which to deal.

This did not work:

Code:
<A HREF=&quot;script.asp?DatabaseVariable=<%=Server.URLEncode(DoVar(rs(&quot;DatabaseVariable&quot;)))%>&quot;>Same Variable Here</a>

But this does:

Code:
<%DatabaseVariable = (DoVar(rs(&quot;DatabaseVariable&quot;)))%>
<A HREF=&quot;script.asp?DatabaseVariable=<%=Server.URLEncode(&quot;DatabaseVariable&quot;)%>&quot;>Same Variable Here</a>

Thanks everybody!

Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top