Solved

decode a URL with excaped characters

Posted on 2014-03-04
6
210 Views
Last Modified: 2014-03-05
Experts were instrumental in supplying me with a solution. There were some developmental updates to the backend of my ESP, and so I'm returning for help.

Here's my initial post with your solution ==>
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27985181.html

Here's the page on the web that is functional ==>
http://e.openmoves.com/profiles/preference-center.html

Use the following URL to sample "functionality" ==>
http://e.openmoves.com/profiles/preference-center.html?email=billgates%40hotmail.com

As I note, the page is functional, except the value of my variable (email=@email@) has been changed. I am collecting data from my email service provider (ESP) to complete the input value for "email". The "@" symbol in the address has been replaced with "%40". I need to unescape that to submit the proper information.

I much appreciate your help. If you cannot extract the javascript form the page I provided, I will gladly send it separately.

Thank you,
JB
0
Comment
Question by:joibrooks
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39904829
var a = decodeURIComponent("billgates%40hotmail.com");

alert( a ); // billgates@hotmail.com
0
 
LVL 58

Expert Comment

by:Gary
ID: 39904831
To decode with js use
decodeURIComponent(string)

But I don't see what this has to do with js, this is something you should be doing at the server...
0
 

Author Comment

by:joibrooks
ID: 39906177
@cathal:
our ESP recently changed the way they return their values. in a trouble ticket that i opened to alert them of the problem, they responded:
"In the following URL, the %40 is actually the correct value and is how the internet is supposed to work. It's called URL encoding."

@cathal and @leakim971:
 i found the decodeURIComponent method online, but I'm not certain how to implement it within my existing javascript. this is where i need your help. please.

the follow script is how i am retrieving the data from the url and placing the value into the email input field.

<script language="javascript">
var gup = function( name ) {
    var results = (new RegExp("[\\?&]"+name+"=([^&#]*)")).exec(window.location.href);
    if ( results == null ) {return ""}
    else {return results[1]}
};

window.onload = function() {
    document.getElementById("emailaddress").value = gup("email");
    document.getElementById("emailaddress2").value = gup("email");
}
</script>

Open in new window


i much appreciate your help.
jb
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39906181
<script language="javascript">
var gup = function( name ) {
    var results = (new RegExp("[\\?&]"+name+"=([^&#]*)")).exec(window.location.href);
    if ( results == null ) {return ""}
    else {return results[1]}
};

window.onload = function() {
    document.getElementById("emailaddress").value = decodeURIComponent( gup("email") );
    document.getElementById("emailaddress2").value = decodeURIComponent( gup("email") );
}
</script>

Open in new window

0
 

Author Comment

by:joibrooks
ID: 39906326
@ leakim971
thank you for another job well done.

jb
0
 

Author Closing Comment

by:joibrooks
ID: 39906337
would i love to go back to school to learn javascript? yes. do i have the time? no. your services are priceless and i recommend experts-exchange often.

jb
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now