JavaScript, firefox 2.0.0.14, IE 7, Remove '%' sign from querystring variable

hello,

I have a problem with a variable that comes from a querystring request.

the name of the variable is:

p_flight

and it could contain 4 different values:

7 a.m. CID to MSN
8 a.m. MSN to CID
4 p.m. CID to MSN
5 p.m. MSN to CID

this variables are passed from a web html form to a perl script that redirects to a success html page with a javascript function that retrieves the variables from the url to display in the success page.

all the variables work fine, but the ones that contain spaces in between on word and another are being displayed with the '%' sign.

is there any way i can remove the sign after the variables is retrieved?

any help would be great.

thank you.
this is the success page:
 
<html>
<head>
<title>Success Page</title>
<script language="javascript">
 
p_name = "";
p_date = "";
p_flight = "";
p_cancel_by = "";
p_emp_number = "";
p_emp_email = "";
 
// Get names
var queryString = window.location.href.substring((window.location.href.indexOf('?') + 1));
var array1 = queryString.split('&'); // Each array element is in format "fieldname=value"
for(var i = 0; i < array1.length; i++){
 var tempArray = array1[i].split('='); // Separate fieldname and value
 eval(tempArray[0] + " = \"" + tempArray[1] + "\"");
}
 
</script>
</head>
<body>
<p>
<script language="javascript"> document.write(p_name);</script> 
<script language="javascript"> document.write(p_date);</script> 
<script language="javascript"> document.write(p_flight);</script> 
<script language="javascript"> document.write(p_cancel_by);</script> 
<script language="javascript"> document.write(p_emp_number);</script> 
<script language="javascript"> document.write(p_emp_email);</script> 
</p>
</form>
</body>
</html>

Open in new window

itortuAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
kszurekConnect With a Mentor Commented:
This code is in Java Script
function urldecode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    
    var ret = str;
       
    ret = ret.replace(/\+/g, '%20');
    ret = decodeURIComponent(ret);
    ret = ret.toString();
 
    return ret;
}

Open in new window

0
 
itortuAuthor Commented:
but my page is html not php
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
itortuAuthor Commented:
oh sorry i see it is javascript.

would you be able to show me how to add this function into my current functionality?

i don't want to mess anything up.
0
 
kszurekConnect With a Mentor Commented:
Try:
<script language="javascript"> document.write(urldecode(p_name));</script>
0
 
itortuAuthor Commented:
got it

<tr><td class="label"><script language="javascript"> document.write(urldecode(p_flight));</script> </td></tr>                                                                                                                                                                                            
0
 
itortuAuthor Commented:
ops you reply just before I did.

anyhow, it di work very nice.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.