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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

whitespace in browser

Status
Not open for further replies.

hacole

Programmer
Jan 19, 2001
16
US
Hello out there. How do I handle whitespace in my value pairs embedded in the URL? Here is my URL:

/...PersonPage.cfm?type=2&CT=3&name=Holly%20Cole

When I try to set my variable in PersonPage.cfm, I'm only getting the part of the string up to the '%20'. (Name: Holly) I'm using <CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE=&quot;Yes&quot;> in my files. Any suggestions???
 
CF won't put whitespace between consecutive characters (to the best of my knowledge) so the &quot;suppress white space&quot; shouldn't be necessary. The only place you might get white space is before and after CF tags where you will likely get extra line breaks. If you can post the code that creates the url, I or someone here can help you fix it. Most likely, you can remedy it with the use of the urlencodedformat() function.

GJ
 
Here is some more information, hopefully this will help....

(code from file1.cfm)....
<td>Quick Name:</td>
<td><input type=&quot;Text&quot; size=&quot;40&quot; maxlength=&quot;40&quot; name=&quot;quick_name&quot; value=&quot;&quot;></td>
<td><input type=&quot;button&quot; value=&quot;Apply&quot; onclick=&quot;QuickName()&quot;></td>

(code in JavaScript)....
var newurl;
var quickname=document.qn.quick_name.value;

newurl=&quot;PersonPage.cfm?type=2&amp;name=&quot;+quickname;
location = newurl;

(url in browser)....
.../PersonPage.cfm?type=2&amp;name=holly%20cole

(code in PersonPage.cfm)....
<CFIF isdefined(&quot;name&quot;)>
<CFSET BUS_NAME = #name#>
</CFIF>

(output of BUS_NAME)....
holly

Where did the rest of the name go???? Why won't it recognize the string after the '%20'?
 
That's odd, try this as a start and let me know what the results are.

on personPage.cfm
<cfoutput>
`#cgi.query_String#` #len(cgi.query_string)#<p>
`#url.name#` #len(url.name)#
</cfoutput>

If I understand you correctly, the first page links to the second page with the correct url. When you look at the url, the end of it reads &quot;PersonPage.cfm?type=2&amp;name=holly%20cole&quot; exactly. Let me know otherwise.

GJ
 
I thought it was odd too!! You are absolutely correct about the first page linking to the second through javascript building the URL, AND that's exactly what the URL looks like...it's all there.

Here's what I got with your code... (I had put a string.length in my javascript to check the string length before passing it in the URL, so that's why &quot;len&quot; is in there.)

`type=2&amp;CT=3&amp;name=holly%20cole&amp;len=10` 38
`holly cole` 10


Thanks for your time and help!!!!

 
I should have asked for this the first time but try this (at the very top of the page). I think you either have duplicate variable names or something is manipulating &quot;name&quot; somewhere in the page before you use it.

GJ

<cfoutput>
`#cgi.query_String#` #len(cgi.query_string)#<p>
`#url.name#` #len(url.name)#<p>
`#name#` #len(name)#
</cfoutput>
 
Well, back from the weekend...
Turns out I just needed to put quotes around my <cfoutput>.

Old code:
<cfoutput><input type=&quot;text&quot;....value=#b_name#>

New code:
<cfoutput><input type=&quot;text&quot;....value=&quot;#b_name#&quot;>

Whitespace problem is solved!! You were correct, it was in CF. But now I've already hit another road block with this mess!! If you're interested, I need to somehow apply the URLEncodedFormat concept to my URL that is being built in JavaScript. Here's what happens when there is a special char in the URL. (Example input: &quot;black &amp; veatch&quot;):

output from your code:
`type=2&amp;CT=3&amp;b_name=black%20&amp;%20veatch&amp;len=14` 44
`black ` 6
`black ` 6


If you have advice, wonderful... Otherwise, thanks for helping me work through the whitespace thing!
 
You can do it on the server side with CF's urlencodedformat() function or on the client side with the JS function escape(). If the JS link doesn't change once the page is loaded, I would do it on the server like this:


....
<script>
var myUrl;

<cfoutput>
myUrl = &quot;page1.cfm?b_name=#urlencodedformat(&quot;black &amp; veatch&quot;)#&quot;;
</cfoutput>

</script>
...........

If the link is created on the client side, you could do it with JS like this:
....
<script>
var myUrl;

function setLocation(x)
{
myUrl = &quot;page1.cfm?name_b=&quot; + escape(x);
}
</script>
...........

I didn't test any of this code so let me know if you have problems.
GJ
 
Hello!! I found it.....

I wanted to let you know this worked perfectly!! Thank you so much for all you time and help. (sorry it took me so long to respond) I really appreciate it. Amazing that one little word - escape - fixed it all!! Thanks,

hacole
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top