We help IT Professionals succeed at work.

Convert %20 to space

net_susan
net_susan asked
on
How do I convert %20 in the two results to spaces (spaces instead of %20)?
<script type="text/javascript">
var query = location.search;
query = (query)? query.substring(1):"";
var queryqu = query.split('&')
var querysplit = new Array();
for (var i=0;i<1;i++) {
var queryValue = queryqu[i].split('=');
if (queryValue[0]) querysplit[queryValue[0]] = unescape(queryValue[1]);
if (queryValue[1] == null) 
   var queryValue1 = " "
else
  var queryValue1=queryValue[1];
}
 
var queryValue3 = " ";
var query2 = location.search;
query2 = (query2)? query2.substring(1):"";
var query2qu = query2.split('&')
var query2split = new Array();
for (var i=0;i<2;i++) {
var query2Value = query2qu[i].split('=');
if (query2Value[0]) query2split[query2Value[0]] = unescape(query2Value[1]);
if  (query2Value[1] == null) 
    var queryValue2 = " "
  	  else {
  		var queryValue2=query2Value[1];
  		var queryValue3=": "; 
   }
}
 
</script>

Open in new window

Comment
Watch Question

HonorGodSoftware Engineer
CERTIFIED EXPERT

Commented:
Use decode()

HonorGodSoftware Engineer
CERTIFIED EXPERT

Commented:
e.g.,

  queryValue1 = decode( queryValue[ 1 ] );
alter you code to use "unescape" everwhere, its currently missing in a couple of places.

the code is a bit unclear to me, what are you trying to do? get the first and second args from the querystring?
<script type="text/javascript">
var query = location.search;
query = (query)? query.substring(1):"";
var queryqu = query.split('&')
var querysplit = new Array();
for (var i=0;i<1;i++) {
var queryValue = queryqu[i].split('=');
if (queryValue[0]) querysplit[queryValue[0]] = unescape(queryValue[1]);
if (queryValue[1] == null) 
   var queryValue1 = " "
else
  var queryValue1=unescape(queryValue[1]);
}
 
var queryValue3 = " ";
var query2 = location.search;
query2 = (query2)? query2.substring(1):"";
var query2qu = query2.split('&')
var query2split = new Array();
for (var i=0;i<2;i++) {
var query2Value = query2qu[i].split('=');
if (query2Value[0]) query2split[query2Value[0]] = unescape(query2Value[1]);
if  (query2Value[1] == null) 
    var queryValue2 = " "
  	  else {
  		var queryValue2=unescape(query2Value[1]);
  		var queryValue3=": "; 
   }
}
 
</script>

Open in new window

Author

Commented:
I tried it just like that and it didn't work.

Author

Commented:
Sorry, my last comment was about decode. I'm trying the next thing now.

Author

Commented:
>>the code is a bit unclear to me, what are you trying to do? get the first and second args from the querystring?

Yes.