?
Solved

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

Posted on 2008-06-19
7
Medium Priority
?
617 Views
Last Modified: 2010-05-18
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

0
Comment
Question by:itortu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 2

Assisted Solution

by:kszurek
kszurek earned 1200 total points
ID: 21822406
0
 

Author Comment

by:itortu
ID: 21822478
but my page is html not php
0
 

Author Comment

by:itortu
ID: 21822496
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 2

Accepted Solution

by:
kszurek earned 1200 total points
ID: 21822507
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
 
LVL 2

Assisted Solution

by:kszurek
kszurek earned 1200 total points
ID: 21822528
Try:
<script language="javascript"> document.write(urldecode(p_name));</script>
0
 

Author Comment

by:itortu
ID: 21822529
got it

<tr><td class="label"><script language="javascript"> document.write(urldecode(p_flight));</script> </td></tr>                                                                                                                                                                                            
0
 

Author Comment

by:itortu
ID: 21822532
ops you reply just before I did.

anyhow, it di work very nice.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question