Forum Moderators: open

Message Too Old, No Replies

Data Transfer

I am transferring data from one page to the next

         

TheSooner3

5:01 am on Dec 15, 2009 (gmt 0)

10+ Year Member



So when I transfer the data using:

function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return unescape(unescape(pair[1]));

anything that has spaces between it will use a + instead of the space. I knew this was going to happen, I just have no idea on how to fix it. Any help please?

daveVk

10:53 am on Dec 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



return decodeURIComponent(pair[1]);

escape/unescape are for html NOT url's

TheSooner3

2:07 pm on Dec 15, 2009 (gmt 0)

10+ Year Member



That didn't seem to work. I tried decodeURLComponent(pair[1]); too just to make sure you didnt type it wrong. I am using that to get the information through the URL to my next page and it does work, just with the + for spaces in those transferred items. Does fixString have anything to do with it?

daveVk

2:37 am on Dec 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[w3schools.com...] gives info on the URI versions
not sure of the origin of the URL version.

Am not aware of problem with + encoded spaces, but sister function encodeURIComponent converts space to %20.

Can you provide before/after example values. ?